:root {
  color-scheme: dark;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #181818;
  color: #eeeeee;
  --surface: #222222;
  --line: #3c3c3c;
  --muted: #b3b3b3;
  --accent: #e2e2e2;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0 auto; max-width: 680px; padding: 24px 16px max(24px, env(safe-area-inset-bottom)); }
button, select, input, textarea { font: inherit; }
button, select, input { min-height: 44px; }
button, select, input, textarea {
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: inherit;
  padding: 10px 12px;
}
button { cursor: pointer; touch-action: manipulation; line-height: 1.25; }
button:disabled { opacity: .55; cursor: wait; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.heading, .editor-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
h1 { font-size: clamp(25px, 7vw, 34px); line-height: 1.15; letter-spacing: -.035em; margin: 0; }
.quiet { background: transparent; border-color: transparent; color: var(--muted); }
.message { margin: 8px 0 20px; }
.message, small, .source-label { font-size: 13px; line-height: 1.5; color: var(--muted); overflow-wrap: anywhere; }
.segments { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 4px; border-bottom: 1px solid var(--line); }
.segments button { background: transparent; border: 0; border-radius: 0; padding-inline: 4px; font-size: 13px; color: var(--muted); }
.segments button[aria-pressed="true"] { color: var(--accent); box-shadow: inset 0 -2px var(--accent); font-weight: 650; }
.toolbar { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 8px; margin: 14px 0 8px; }
.toolbar select { width: 100%; min-width: 0; }
.toolbar button { font-size: 13px; }
#search { width: 100%; margin-bottom: 20px; }
#cards { display: grid; gap: 12px; }
article { padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
article h2 { font-size: 17px; line-height: 1.45; margin: 0 0 10px; white-space: pre-wrap; overflow-wrap: anywhere; }
.repeat-card h2 { color: var(--accent); }
.comparison { padding: 12px 0; border-top: 1px solid var(--line); }
.comparison small { display: block; }
.comparison p { margin: 4px 0 0; line-height: 1.5; overflow-wrap: anywhere; white-space: pre-wrap; }
.comparison button { width: 100%; margin-top: 12px; }
.repeat-actions { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; }
.repeat-actions button { font-size: 13px; }
.repeat-actions button:last-child { grid-column: 1 / -1; }
.repeat-options:not(:empty) { margin-top: 12px; padding-top: 8px; border-top: 1px solid var(--line); overflow-wrap: anywhere; }
.repeat-options button { margin: 4px 4px 4px 0; }
blockquote { margin: 10px 0; padding-left: 10px; border-left: 2px solid var(--line); color: var(--muted); line-height: 1.5; overflow-wrap: anywhere; white-space: pre-wrap; }
a { color: var(--accent); margin-left: 8px; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px; }
.actions > small { flex: 1; }
.actions button { font-size: 13px; }
.actions button:first-of-type { color: var(--accent); }
.record-details { color: var(--muted); }
.record-details summary { min-height: 44px; display: grid; place-items: center; cursor: pointer; list-style: none; padding: 0 10px; }
.record-details summary::-webkit-details-marker { display: none; }
footer { display: flex; justify-content: space-between; margin-top: 18px; gap: 8px; }
dialog { width: min(100% - 24px, 600px); max-height: calc(100dvh - 32px); border: 1px solid var(--line); border-radius: 16px; background: #181818; color: inherit; padding: 16px; }
dialog::backdrop { background: #080808c9; }
.editor-heading h2 { margin: 0; }
.context-title, .editor-footer p { color: var(--muted); line-height: 1.5; overflow-wrap: anywhere; }
textarea { width: 100%; min-height: 140px; font-size: 16px; line-height: 1.5; resize: vertical; }
.editor-footer { display: flex; flex-wrap: wrap; gap: 8px; justify-content: space-between; }
.editor-footer p { flex-basis: 100%; margin: 0; }
.primary { background: var(--accent); color: #202020; border-color: transparent; font-weight: 650; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.list-entry { display: grid; gap: 5px; width: 100%; padding: 14px 36px 14px 16px; position: relative; text-align: left; background: var(--surface); }
.list-entry::after { content: '›'; position: absolute; right: 15px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 21px; }
.list-preview { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; overflow-wrap: anywhere; font-size: 16px; line-height: 1.4; }
#detail { padding: 0; overflow: auto; }
.detail-header { padding: 12px 20px 16px; border-bottom: 1px solid var(--line); }
.detail-header h2 { margin: 8px 0 0; font-size: 24px; }
#detail-back { width: 44px; height: 44px; padding: 0; font-size: 22px; line-height: 1; border: 1px solid var(--line); }
#detail-body { padding: 20px; }
#detail-status { margin: 0 20px 16px; color: var(--muted); }
#detail-status:empty { display: none; }
#detail .repeat-card { padding: 0; border: 0; background: transparent; }
#detail .comparison { padding: 14px; margin-bottom: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
#detail .repeat-actions { margin-top: 18px; }
.thought-text { margin: 0 0 16px; font-size: 18px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
@media (max-width: 540px) {
 #detail { margin: 0; width: 100%; max-width: none; height: 100%; max-height: none; border: 0; border-radius: 0; padding-bottom: env(safe-area-inset-bottom); }
}

.segments { grid-template-columns: repeat(2,minmax(0,1fr)); }
#home { font: inherit; color: inherit; background: transparent; border: 0; padding: 0; }
#category-title { margin: 18px 0 10px; font-size: 20px; }
#cards, #category-title { touch-action: pan-y; }
.inline-context { margin-top: 20px; border-top: 1px solid var(--line); padding-top: 12px; }
.inline-context h3 { margin: 0 0 8px; }
.inline-context p { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.5; }
.category-heading, .color-setting { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.category-heading button { font-size: 12px; }
.category-tags { display: flex; flex-wrap: wrap; gap: 4px 10px; }
.category-tag { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; }
.category-tag[data-color]:not([data-color=""])::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--tag-color, currentColor); }
[data-color="sand"] { --tag-color: #c3a378; }
[data-color="green"] { --tag-color: #85ac83; }
[data-color="teal"] { --tag-color: #79aaa5; }
[data-color="blue"] { --tag-color: #829fc2; }
[data-color="purple"] { --tag-color: #aa95c3; }
[data-color="rose"] { --tag-color: #bf8e9d; }
.color-setting { padding: 8px 0; border-top: 1px solid var(--line); }
.color-setting select { max-width: 52%; }
.color-setting { flex-wrap: wrap; }
.category-actions { display: flex; gap: 8px; flex-basis: 100%; }
.category-actions button { font-size: 13px; }
.heading-actions { display: flex; flex: 0 0 auto; justify-content: flex-end; gap: 0; }
.telegram-fullscreen {
 --screen-top: calc(max(env(safe-area-inset-top), var(--tg-safe-area-inset-top, 0px)) + var(--tg-content-safe-area-inset-top, 0px));
 --screen-bottom: calc(max(env(safe-area-inset-bottom), var(--tg-safe-area-inset-bottom, 0px)) + var(--tg-content-safe-area-inset-bottom, 0px));
}
.telegram-fullscreen body { padding-top: var(--screen-top); padding-bottom: calc(16px + var(--screen-bottom)); }
.telegram-fullscreen dialog { max-height: calc(100dvh - var(--screen-top) - var(--screen-bottom) - 16px); }
@media (max-width: 540px) {
 .telegram-fullscreen #detail { margin-top: var(--screen-top); }
}

.heading h1 { font-size: 22px; white-space: nowrap; }
.heading-actions button { width: 44px; height: 44px; padding: 0; font-size: 22px; }
#message:empty { display: none; }
.category-tag[data-color]:not([data-color=""]) { color: var(--tag-color, var(--muted)); }
.card-tagging { margin: 0 0 14px; }
.card-tagging summary { cursor: pointer; color: var(--muted); }
.card-tagging label { display: flex; align-items: center; gap: 8px; min-height: 36px; }
.card-tagging input { min-height: auto; }
.card-tagging .category-tag { font-size: 14px; }
.category-custom-color { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 8px; flex-basis: 100%; }
.category-custom-color input[type="color"] { width: 44px; height: 44px; padding: 4px; }
.category-custom-color input[type="text"] { width: 100%; min-width: 0; font-size: 16px; }
.category-custom-color button { padding-inline: 8px; font-size: 13px; }

.review-decisions {
 display: grid;
 grid-template-columns: repeat(2, minmax(0, 1fr));
 gap: 8px;
 max-width: 460px;
 margin: 12px auto 0;
}
.review-decisions .review-approve { background: #253b30; border-color: #42634e; color: #d3ebda; }
.review-decisions .review-reject { background: #303030; }
.review-decisions .review-later,
.review-decisions .review-fix { grid-column: 1 / -1; }
#voice-new { background: #253b30; border-color: #42634e; color: #d3ebda; }
#context-title:empty { display: none; }
.segments { grid-template-columns: repeat(3,minmax(0,1fr)); }
.rejected-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 6px; }
