body {
    font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    background-color: #f4f4f4;
    margin: 0;
}

.container {
    background-color: white;
    padding: 24px;
    border-radius: 8px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    max-width: 900px;
    width: 92%;
}

h1 {
    text-align: center;
    margin-top: 8px;
    font-size: 1.4em;
}

.lead {
    color: #555;
    font-size: 0.95em;
    text-align: center;
    margin-top: 0;
}

.navigation-links {
    margin-bottom: 8px;
    font-size: 0.9em;
}

.navigation-links a {
    color: #007aff;
    text-decoration: none;
}

.navigation-links a:hover {
    text-decoration: underline;
}

code {
    background: #f0f0f0;
    padding: 1px 4px;
    border-radius: 3px;
    font-size: 0.9em;
}

details {
    margin: 12px 0;
}

details summary {
    cursor: pointer;
    font-weight: bold;
}

details ol {
    padding-left: 1.5em;
    line-height: 1.7;
}

.syntax-example {
    background: #f7f7f7;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 12px;
    font-size: 0.85em;
    overflow-x: auto;
    line-height: 1.5;
}

.editor {
    display: flex;
    gap: 20px;
    margin: 16px 0;
    align-items: flex-start;
}

@media (max-width: 720px) {
    .editor {
        flex-direction: column;
    }
}

.edit-pane {
    flex: 1;
    min-width: 0;
}

.toolbar,
.pal-row,
.pos-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.tb-label {
    font-size: 0.85em;
    font-weight: bold;
    color: #555;
}

.mode-group,
.side-group {
    display: inline-flex;
    border: 1px solid #ccc;
    border-radius: 6px;
    overflow: hidden;
}

.mode-btn,
.side-btn {
    background: #fff;
    color: #333;
    border: none;
    border-right: 1px solid #ccc;
    border-radius: 0;
    padding: 6px 10px;
    font-size: 0.85em;
    transition: background-color 0.15s;
}

.mode-btn:last-child,
.side-btn:last-child {
    border-right: none;
}

.mode-btn:hover:not(.active),
.side-btn:hover:not(.active),
.piece-btn:hover:not(.active) {
    background: #eaf3ff;
}

.mode-btn.active,
.side-btn.active {
    background: #007aff;
    color: #fff;
}

.palette {
    background: #f7f7f7;
    border-radius: 6px;
    padding: 10px;
    margin-bottom: 12px;
}

.palette .pal-row:last-child {
    margin-bottom: 0;
}

.pal-row.pieces {
    gap: 6px;
}

.piece-btn {
    width: 40px;
    height: 40px;
    background: #fff;
    color: #1f1409;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 1.2em;
    font-weight: bold;
    padding: 0;
}

.piece-btn.active {
    background: #f3d9a4;
    border-color: #6b4a23;
    box-shadow: 0 0 0 2px #6b4a23 inset;
}

.piece-btn.eraser {
    font-size: 0.9em;
    color: #888;
}

.promote-toggle,
.pos-controls .chk {
    font-size: 0.85em;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.pos-controls label {
    font-size: 0.85em;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.pos-controls select,
.pos-controls input[type="text"] {
    padding: 4px 6px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 0.9em;
    background: #fff;
}

.caption-label input {
    width: 140px;
}

.hands-editor {
    margin: 0 0 10px;
    font-size: 0.85em;
}

.hand-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin: 6px 0;
}

.hand-head {
    font-weight: bold;
    width: 3.5em;
}

.hand-piece {
    display: inline-flex;
    align-items: center;
    gap: 2px;
}

.hand-piece button {
    width: 22px;
    height: 22px;
    padding: 0;
    font-size: 0.85em;
    background: #e9e9e9;
    color: #333;
    border-radius: 4px;
}

.hand-piece button:hover {
    background: #d8d8d8;
}

.hand-count {
    min-width: 1.4em;
    text-align: center;
}

.status {
    min-height: 1.3em;
    font-size: 0.82em;
    color: #007aff;
    margin-bottom: 8px;
}

.input-area {
    flex: 1;
    min-width: 0;
}

.input-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
    gap: 12px;
    flex-wrap: wrap;
}

.input-label {
    font-weight: bold;
    font-size: 0.95em;
}

.sample-label {
    font-size: 0.85em;
    color: #555;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.sample-label select {
    padding: 4px 6px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 0.9em;
    background: white;
}

textarea {
    width: 100%;
    box-sizing: border-box;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-family: "SF Mono", Menlo, Consolas, monospace;
    font-size: 0.9em;
    line-height: 1.5;
    resize: vertical;
}

textarea:focus {
    outline: none;
    border-color: #007aff;
}

.input-meta {
    display: flex;
    justify-content: flex-end;
    margin-top: 4px;
    font-size: 0.85em;
    min-height: 1.2em;
}

.input-meta .error {
    color: #c0392b;
    font-weight: bold;
}

.preview-area {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.preview-box {
    width: 100%;
    min-height: 320px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fafafa;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 16px;
    box-sizing: border-box;
    overflow: auto;
}

.preview-box svg {
    max-width: 100%;
    height: auto;
}

.preview-box .placeholder {
    color: #888;
    font-size: 0.9em;
    text-align: center;
    margin: 0;
}

.download-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}

button {
    padding: 8px 14px;
    cursor: pointer;
    border: none;
    border-radius: 6px;
    background-color: #007aff;
    color: white;
    font-size: 0.9em;
    transition: background-color 0.2s;
}

button:hover:not(:disabled) {
    background-color: #005bbf;
}

button:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

#downloadSvgBtn {
    background-color: #34c759;
}

#downloadSvgBtn:hover:not(:disabled) {
    background-color: #28a745;
}

.ref-table {
    border-collapse: collapse;
    width: 100%;
    font-size: 0.85em;
    margin-top: 8px;
}

.ref-table th,
.ref-table td {
    border: 1px solid #e0e0e0;
    padding: 6px 8px;
    text-align: left;
    vertical-align: top;
}

.ref-table th {
    background: #f7f7f7;
}

.note {
    font-size: 0.85em;
    color: #666;
    margin-top: 10px;
}
