:root {
    --primary-color: #0d6efd;
    --primary-hover: #0b5ed7;
    --secondary-color: #6c757d;
    --secondary-hover: #5c636a;
    --dark-bg: #121212;
    --dark-text: #e0e0e0;
    --dark-fieldset-bg: #1e1e1e;
    --dark-border: #333;
    --dark-code-bg: #2d2d2d;
    --dark-log-bg: #2a2a2a;
    --dark-input-bg: #2d2d2d;
    --dark-input-text: #e0e0e0
}

body {
    margin: 0;
    padding: 0;
    font-family: system-ui,-apple-system,"Segoe UI","Microsoft YaHei","PingFang SC","Hiragino Sans GB","Noto Sans CJK SC",sans-serif
}

button {
    padding: .375rem .75rem;
    border: 1px solid var(--primary-color);
    border-radius: .375rem;
    margin-bottom: 5px;
    white-space: nowrap;
    cursor: pointer;
    font-size: .9rem
}

button:disabled {
    opacity: .65
}

button.primary {
    color: #fff;
    background-color: var(--primary-color)
}

button.primary:hover {
    color: #fff;
    border-color: var(--primary-hover);
    background-color: var(--primary-hover)
}

button.secondary {
    color: #fff;
    background-color: var(--secondary-color);
    border-color: var(--secondary-color)
}

button.secondary:hover {
    color: #fff;
    border-color: var(--secondary-hover);
    background-color: var(--secondary-hover)
}

h3 {
    padding-bottom: .3em;
    border-bottom: 1px solid #ccc;
    text-align: center
}

fieldset {
    border: none;
    box-shadow: 0 .5rem .5rem rgba(0,0,0,.2);
    background-color: #f8f9fa;
    padding: 10px;
    margin-bottom: 16px;
    border-radius: 4px
}

fieldset legend {
    font-weight: 700;
    color: rgba(0,0,255,.6)
}

code {
    padding: .2em .4em;
    margin: 0;
    font-size: 85%;
    background: #ccc;
    border-radius: 3px
}

input[type=number],input[type=text],select {
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.5;
    color: #212529;
    border: 1px solid #dee2e6;
    border-radius: .375rem;
    padding: .2rem .75rem;
    max-width: 100%;
    box-sizing: border-box
}

input[type=file] {
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.5;
    color: #212529;
    max-width: 100%
}

input::file-selector-button {
    font-size: .9rem;
    font-weight: 400;
    line-height: 1.5;
    border: 1px solid var(--primary-color);
    border-radius: .375rem;
    cursor: pointer
}

select {
    padding: .3rem 2.25rem .3rem .75rem
}

option,select {
    font-family: inherit
}

.pcf-font-size {
    min-width: 90px;
    padding-right: 1.5rem
}

input:focus,select:focus {
    border: 1px solid #86b7fe;
    box-shadow: 0 0 4px rgba(0,120,215,.8);
    outline: 0
}

input[type=number]:disabled,input[type=text]:disabled,select:disabled {
    opacity: .65;
    cursor: not-allowed;
    background-color: #e9ecef;
    color: #6c757d
}

label {
    margin-right: 4px;
    white-space: nowrap
}

.main {
    width: 100%;
    max-width: 950px;
    margin: 0 auto;
    padding: 0 1rem;
    background: #fff;
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.5;
    box-sizing: border-box
}

.footer {
    display: flex;
    gap: 10px;
    font-size: .8rem;
    color: #666;
    flex-wrap: wrap;
    margin: 1rem 0
}

.footer .links {
    display: flex;
    align-items: center
}

.footer .links a {
    color: #666;
    text-decoration: none;
    position: relative;
    padding: 0 8px
}

.footer .links a:first-child {
    padding-left: 0
}

.footer .links a:not(:last-child)::after {
    content: "•";
    position: absolute;
    right: -4px;
    color: #999
}

.footer a:hover {
    color: #0d6efd;
    text-decoration: underline
}

.flex-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 8px
}

.schedule-editor-hint {
    font-size: 12px;
    color: #666;
    margin: 4px 0 8px 0
}

.schedule-table-container {
    width: 100%;
    overflow: auto;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    background: #fff
}

table.schedule-editor-table {
    border-collapse: collapse;
    width: 100%;
    min-width: 520px
}

table.schedule-editor-table td,table.schedule-editor-table th {
    border: 1px solid #dee2e6;
    padding: 0;
    text-align: center;
    vertical-align: middle
}

table.schedule-editor-table th {
    background: #f6f7f9;
    font-weight: 600;
    padding: 6px 8px;
    white-space: nowrap
}

input.schedule-cell-input {
    width: 100%;
    min-width: 70px;
    height: 32px;
    border: none;
    border-radius: 0;
    padding: 4px 6px;
    text-align: center;
    outline: 0
}

input.schedule-cell-input:focus {
    box-shadow: inset 0 0 0 2px rgba(13,110,253,.35)
}

.todo-editor-hint {
    font-size: 12px;
    color: #666;
    margin: 4px 0 8px 0
}

.card-editor-hint {
    font-size: 12px;
    color: #666;
    margin: 4px 0 8px 0
}

.card-tools {
    width: 100%;
    padding: 8px;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    background: #fff
}

body.dark-mode .card-tools {
    background: var(--dark-fieldset-bg);
    border-color: var(--dark-border)
}

.card-editor-hint {
    padding: 6px 8px;
    border: 1px dashed #ced4da;
    border-radius: 6px;
    background: #fafafa
}

body.dark-mode .card-editor-hint {
    background: var(--dark-code-bg);
    border-color: var(--dark-border);
    color: var(--dark-text)
}

.wifi-editor-hint {
    font-size: 12px;
    color: #666;
    margin: 4px 0 8px 0
}

.wifi-tools {
    width: 100%;
    padding: 8px;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    background: #fff
}

.wifi-form {
    display: grid;
    grid-template-columns: 1.2fr 1.2fr 0.8fr auto;
    gap: 10px;
    align-items: end
}

.wifi-field {
    display: flex;
    flex-direction: column;
    gap: 6px
}

.wifi-field label {
    font-size: 12px;
    color: #556
}

.wifi-field--inline {
    justify-content: flex-end
}

.wifi-check {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    user-select: none
}

.wifi-password {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
    align-items: center
}

.wifi-password button {
    margin-bottom: 0
}

.wifi-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-top: 8px
}

.wifi-preview {
    margin-top: 10px;
    padding: 10px;
    border: 1px solid #dee2e6;
    border-radius: 10px;
    background: linear-gradient(180deg,#fff 0,#fbfbfc 100%)
}

.wifi-qr-wrap {
    width: 220px;
    max-width: 100%;
    aspect-ratio: 1/1;
    position: relative;
    margin: 0 auto;
    border-radius: 14px;
    background: #fff;
    border: 1px solid #e6e9ef;
    box-shadow: 0 6px 18px rgba(0,0,0,.06);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden
}

.wifi-qr {
    width: 92%;
    height: 92%;
    display: flex;
    align-items: center;
    justify-content: center
}

.wifi-qr svg {
    width: 100%;
    height: 100%
}

.wifi-qr-logo {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%,-50%);
    width: 44px;
    height: 44px;
    border-radius: 999px;
    background: rgba(255,255,255,.94);
    border: 1px solid #e6e9ef;
    color: #111;
    display: flex;
    align-items: center;
    justify-content: center
}

.wifi-meta {
    margin-top: 10px;
    display: grid;
    gap: 8px
}

.wifi-meta-row {
    display: grid;
    grid-template-columns: 64px 1fr;
    gap: 10px;
    align-items: center
}

.wifi-meta-row .k {
    font-size: 12px;
    color: #667
}

.wifi-meta-row .v {
    font-weight: 600;
    color: #111;
    word-break: break-all
}

.wifi-payload-row {
    display: grid;
    gap: 6px
}

.wifi-payload-label {
    font-size: 12px;
    color: #667
}

#wifi-payload {
    width: 100%;
    min-height: 64px;
    resize: vertical;
    font-family: ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;
    font-size: 12px;
    line-height: 1.5;
    background: #f6f7f9;
    border: 1px solid #e6e9ef;
    border-radius: 8px;
    padding: 8px;
    box-sizing: border-box;
    color: #111
}

.wifi-payload-actions {
    display: flex;
    justify-content: flex-end
}

.wifi-payload-actions button {
    margin-bottom: 0
}

body.dark-mode .wifi-tools {
    background: var(--dark-fieldset-bg);
    border-color: var(--dark-border)
}

body.dark-mode .wifi-preview {
    background: linear-gradient(180deg,var(--dark-fieldset-bg) 0,#141414 100%);
    border-color: var(--dark-border)
}

body.dark-mode .wifi-qr-wrap {
    background: #0f0f0f;
    border-color: var(--dark-border);
    box-shadow: 0 8px 24px rgba(0,0,0,.35)
}

body.dark-mode .wifi-qr-logo {
    background: rgba(20,20,20,.92);
    border-color: var(--dark-border);
    color: var(--dark-text)
}

body.dark-mode .wifi-meta-row .v {
    color: var(--dark-text)
}

body.dark-mode #wifi-payload {
    background: var(--dark-code-bg);
    border-color: var(--dark-border);
    color: var(--dark-text)
}

.wifi-editor-hint {
    padding: 6px 8px;
    border: 1px dashed #ced4da;
    border-radius: 6px;
    background: #fafafa
}

body.dark-mode .wifi-editor-hint {
    background: var(--dark-code-bg);
    border-color: var(--dark-border);
    color: var(--dark-text)
}

.todo-table-container {
    width: 100%;
    overflow: auto;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    background: #fff
}

table.todo-editor-table {
    border-collapse: collapse;
    width: 100%;
    min-width: 520px
}

table.todo-editor-table td,table.todo-editor-table th {
    border: 1px solid #dee2e6;
    padding: 0;
    text-align: center;
    vertical-align: middle
}

table.todo-editor-table th {
    background: #f6f7f9;
    font-weight: 600;
    padding: 6px 8px;
    white-space: nowrap
}

input.todo-item-input {
    width: 100%;
    min-width: 260px;
    height: 32px;
    border: none;
    border-radius: 0;
    padding: 4px 8px;
    text-align: left;
    outline: 0
}

input.todo-item-input:focus {
    box-shadow: inset 0 0 0 2px rgba(13,110,253,.35)
}

input.todo-done-checkbox {
    width: 18px;
    height: 18px
}

.flex-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center
}

.flex-group.right {
    margin-left: auto
}

.debug {
    display: none!important
}

.log-container {
    width: 100%;
    min-height: 100px;
    max-height: 300px;
    margin: 0;
    padding: 5px;
    background: #ddd;
    overflow-y: auto;
    overflow-x: hidden;
    font-family: ui-monospace,SFMono-Regular,SF Mono,Menlo,Consolas,Liberation Mono,monospace;
    box-sizing: border-box;
    word-break: break-word
}

.log-container .log-line {
    padding: 2px 0
}

.log-container .action,.log-container .time {
    display: inline-block;
    white-space: nowrap
}

.log-container .time {
    color: #333;
    margin-right: .5em
}

.log-container .action {
    color: #666;
    margin-right: .5em
}

.canvas-container canvas {
    border: #000 solid 1px;
    max-width: 100%;
    height: auto;
    display: block;
    margin: 0 auto;
    touch-action: none
}

.canvas-container.crop-mode canvas {
    border: 2px dashed var(--primary-color);
    cursor: grab
}

.status-bar {
    display: none;
    font-size: 85%;
    color: #666;
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px dotted #aaa
}

canvas.text-placement-mode {
    border: 2px dashed var(--primary-color)!important;
    cursor: text!important
}

.canvas-title {
    display: none;
    text-align: center;
    margin-bottom: 5px;
    color: var(--primary-color)
}

.canvas-tools {
    margin-top: 10px;
    justify-content: center
}

.brush-tools,.crop-tools,.text-tools {
    display: none
}

.schedule-tools {
    display: flex
}

.canvas-container.brush-mode .brush-tools,.canvas-container.crop-mode .crop-tools,.canvas-container.eraser-mode .brush-tools,.canvas-container.text-mode .brush-tools,.canvas-container.text-mode .text-tools {
    display: flex
}

.canvas-container.crop-mode .brush-tools,.canvas-container.crop-mode .text-tools,.canvas-container.crop-mode .tool-buttons {
    display: none
}

.tool-button {
    width: 36px;
    height: 36px;
    font-size: 1.2rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-right: 5px;
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 0;
    cursor: pointer;
    transition: all .2s ease
}

.tool-button:hover {
    background-color: #e9ecef;
    border-color: #ced4da
}

.tool-button.active {
    background-color: var(--primary-color);
    color: #fff;
    border-color: var(--primary-color)
}

.tool-button.tool-button--card {
    background-image: url("data:image/svg+xml,%3Csvg%20xmlns%3D'http%3A//www.w3.org/2000/svg'%20viewBox%3D'0%200%2024%2024'%3E%3Cdefs%3E%3ClinearGradient%20id%3D'g'%20x1%3D'0'%20y1%3D'0'%20x2%3D'1'%20y2%3D'1'%3E%3Cstop%20offset%3D'0'%20stop-color%3D'%230ea5e9'/%3E%3Cstop%20offset%3D'1'%20stop-color%3D'%23a855f7'/%3E%3C/linearGradient%3E%3C/defs%3E%3Crect%20x%3D'3'%20y%3D'6'%20width%3D'18'%20height%3D'12'%20rx%3D'2.6'%20fill%3D'url(%23g)'/%3E%3Crect%20x%3D'5'%20y%3D'9'%20width%3D'9'%20height%3D'2'%20rx%3D'1'%20fill%3D'%23fff'%20opacity%3D'0.95'/%3E%3Crect%20x%3D'5'%20y%3D'12.5'%20width%3D'7'%20height%3D'1.6'%20rx%3D'0.8'%20fill%3D'%23fff'%20opacity%3D'0.9'/%3E%3Crect%20x%3D'15.3'%20y%3D'9'%20width%3D'4.2'%20height%3D'4.2'%20rx%3D'0.7'%20fill%3D'%23fff'%20opacity%3D'0.98'/%3E%3Crect%20x%3D'16.0'%20y%3D'9.7'%20width%3D'0.9'%20height%3D'0.9'%20fill%3D'%230f172a'/%3E%3Crect%20x%3D'17.2'%20y%3D'9.7'%20width%3D'0.9'%20height%3D'0.9'%20fill%3D'%230f172a'/%3E%3Crect%20x%3D'18.4'%20y%3D'9.7'%20width%3D'0.9'%20height%3D'0.9'%20fill%3D'%230f172a'/%3E%3Crect%20x%3D'16.0'%20y%3D'10.9'%20width%3D'0.9'%20height%3D'0.9'%20fill%3D'%230f172a'/%3E%3Crect%20x%3D'18.4'%20y%3D'10.9'%20width%3D'0.9'%20height%3D'0.9'%20fill%3D'%230f172a'/%3E%3Crect%20x%3D'16.0'%20y%3D'12.1'%20width%3D'0.9'%20height%3D'0.9'%20fill%3D'%230f172a'/%3E%3Crect%20x%3D'17.2'%20y%3D'12.1'%20width%3D'0.9'%20height%3D'0.9'%20fill%3D'%230f172a'/%3E%3Crect%20x%3D'18.4'%20y%3D'12.1'%20width%3D'0.9'%20height%3D'0.9'%20fill%3D'%230f172a'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 22px 22px
}

.tool-button.tool-button--card.active {
    background-image: url("data:image/svg+xml,%3Csvg%20xmlns%3D'http%3A//www.w3.org/2000/svg'%20viewBox%3D'0%200%2024%2024'%3E%3Crect%20x%3D'3'%20y%3D'6'%20width%3D'18'%20height%3D'12'%20rx%3D'2.6'%20fill%3D'none'%20stroke%3D'%23fff'%20stroke-width%3D'2'/%3E%3Cpath%20d%3D'M6%2010h8'%20stroke%3D'%23fff'%20stroke-width%3D'2'%20stroke-linecap%3D'round'/%3E%3Cpath%20d%3D'M6%2013h6'%20stroke%3D'%23fff'%20stroke-width%3D'2'%20stroke-linecap%3D'round'/%3E%3Crect%20x%3D'15.3'%20y%3D'9'%20width%3D'4.2'%20height%3D'4.2'%20rx%3D'0.7'%20fill%3D'none'%20stroke%3D'%23fff'%20stroke-width%3D'1.6'/%3E%3Crect%20x%3D'16.0'%20y%3D'9.7'%20width%3D'0.9'%20height%3D'0.9'%20fill%3D'%23fff'/%3E%3Crect%20x%3D'17.2'%20y%3D'10.9'%20width%3D'0.9'%20height%3D'0.9'%20fill%3D'%23fff'/%3E%3Crect%20x%3D'18.4'%20y%3D'12.1'%20width%3D'0.9'%20height%3D'0.9'%20fill%3D'%23fff'/%3E%3C/svg%3E")
}

.tool-button.hide {
    display: none
}

@media (max-width: 768px) {
    .flex-container {
        flex-direction:column
    }

    .flex-container.options .flex-group label {
        min-width: 80px
    }

    .flex-group.right {
        margin-left: 0
    }

    .canvas-tools.flex-container {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center
    }

    .canvas-tools .flex-group {
        justify-content: center;
        width: 100%
    }

    .log-container {
        height: 150px;
        margin-top: 10px
    }

    fieldset {
        padding: 8px
    }

    button {
        width: auto
    }

    input[type=number],input[type=text],select {
        max-width: 100%;
        margin-bottom: 5px
    }
}

body.dark-mode .debug {
    display: flex!important
}

body.dark-mode,body.dark-mode .main {
    background-color: var(--dark-bg);
    color: var(--dark-text)
}

body.dark-mode fieldset {
    background-color: var(--dark-fieldset-bg);
    box-shadow: 0 .5rem .5rem rgba(0,0,0,.5)
}

body.dark-mode h3 {
    border-bottom: 1px solid var(--dark-border);
    color: var(--dark-text)
}

body.dark-mode code {
    background: var(--dark-code-bg);
    color: #ff9800
}

body.dark-mode input[type=number],body.dark-mode input[type=text],body.dark-mode select {
    background-color: var(--dark-input-bg);
    color: var(--dark-input-text);
    border-color: var(--dark-border)
}

body.dark-mode input[type=number]:disabled,body.dark-mode input[type=text]:disabled,body.dark-mode select:disabled {
    background-color: #1a1a1a;
    color: #666;
    border-color: #2a2a2a
}

body.dark-mode input[type=file] {
    color: var(--dark-input-text);
    background-color: transparent;
    border-color: var(--dark-border)
}

body.dark-mode input[type=file]::file-selector-button {
    background-color: var(--dark-fieldset-bg);
    color: var(--dark-input-text);
    border-color: var(--dark-border)
}

body.dark-mode input[type=file]::file-selector-button:hover {
    background-color: #333;
    border-color: #444
}

body.dark-mode .log-container {
    background: var(--dark-log-bg);
    border: 1px solid var(--dark-border)
}

body.dark-mode .log-container .time {
    color: #8bc34a
}

body.dark-mode .log-container .action {
    color: #03a9f4
}

body.dark-mode fieldset legend {
    color: #64b5f6
}

body.dark-mode .footer .links a:not(:last-child)::after {
    color: #666
}

body.dark-mode .footer {
    color: #999
}

body.dark-mode .footer a {
    color: #999
}

body.dark-mode .footer a:hover {
    color: #64b5f6
}

body.dark-mode .tool-button {
    background-color: var(--dark-input-bg);
    border-color: var(--dark-border);
    color: var(--dark-text)
}

body.dark-mode .tool-button:hover {
    background-color: #3a3a3a;
    border-color: #444
}

body.dark-mode .tool-button.active {
    background-color: var(--primary-color);
    color: #fff;
    border-color: var(--primary-hover)
}

.tool-button.tool-button--wifi {
    background-image: url("data:image/svg+xml,%3Csvg%20xmlns%3D'http%3A//www.w3.org/2000/svg'%20viewBox%3D'0%200%2024%2024'%3E%3Cpath%20d%3D'M2.5%209.5c5.6-5.6%2013.4-5.6%2019%200'%20fill%3D'none'%20stroke%3D'%23111'%20stroke-width%3D'2'%20stroke-linecap%3D'round'/%3E%3Cpath%20d%3D'M5.8%2012.8c3.8-3.8%208.6-3.8%2012.4%200'%20fill%3D'none'%20stroke%3D'%23111'%20stroke-width%3D'2'%20stroke-linecap%3D'round'/%3E%3Cpath%20d%3D'M9.2%2016.2c2.0-2.0%203.6-2.0%205.6%200'%20fill%3D'none'%20stroke%3D'%23111'%20stroke-width%3D'2'%20stroke-linecap%3D'round'/%3E%3Ccircle%20cx%3D'12'%20cy%3D'19'%20r%3D'1.4'%20fill%3D'%23111'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 22px 22px
}

.tool-button.tool-button--wifi.active {
    background-image: url("data:image/svg+xml,%3Csvg%20xmlns%3D'http%3A//www.w3.org/2000/svg'%20viewBox%3D'0%200%2024%2024'%3E%3Cpath%20d%3D'M2.5%209.5c5.6-5.6%2013.4-5.6%2019%200'%20fill%3D'none'%20stroke%3D'%23fff'%20stroke-width%3D'2'%20stroke-linecap%3D'round'/%3E%3Cpath%20d%3D'M5.8%2012.8c3.8-3.8%208.6-3.8%2012.4%200'%20fill%3D'none'%20stroke%3D'%23fff'%20stroke-width%3D'2'%20stroke-linecap%3D'round'/%3E%3Cpath%20d%3D'M9.2%2016.2c2.0-2.0%203.6-2.0%205.6%200'%20fill%3D'none'%20stroke%3D'%23fff'%20stroke-width%3D'2'%20stroke-linecap%3D'round'/%3E%3Ccircle%20cx%3D'12'%20cy%3D'19'%20r%3D'1.4'%20fill%3D'%23fff'/%3E%3C/svg%3E")
}

@media (max-width: 768px) {
    .wifi-form {
        grid-template-columns:1fr
    }

    .wifi-qr-wrap {
        width: 200px
    }
}
