@layer reset, base, layout, components, responsive;
@layer reset {
  * { box-sizing: border-box; }
  body, h1, h2, h3, p { margin: 0; }
  button, input { font: inherit; }
  button, a, input { -webkit-tap-highlight-color: transparent; }
  button { cursor: pointer; color: inherit; touch-action: manipulation; }
  button:disabled { cursor: wait; opacity: .55; }
  a { color: inherit; text-decoration: none; }
  [hidden] { display: none !important; }
}
@layer base {
  :root { font-family: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, sans-serif; color: #263246; background: #f3f5f9; font-synthesis: none; --blue: #3158ce; --muted: #67748a; --line: #dce2eb; }
  body { font-size: 1rem; line-height: 1.5; }
  :focus-visible { outline: 3px solid #3158ce; outline-offset: 3px; }
  h1 { font-size: 1.4rem; font-weight: 700; letter-spacing: -.025em; line-height: 1.3; }
  h2 { font-size: 1.1rem; font-weight: 650; letter-spacing: -.015em; }
  svg { flex-shrink: 0; vertical-align: middle; }
  .category-ich { --category: #7240b5; --category-ink: #32184f; --category-soft: #c7a9ef; --category-border: #9564d2; --category-container: #f1eafb; --category-done: #e7dcf3; --category-done-border: #c8b4dc; }
  .category-wir { --category: #b83261; --category-ink: #54162b; --category-soft: #efa8bd; --category-border: #d35f85; --category-container: #fbeaf0; --category-done: #f3dce4; --category-done-border: #dcb9c6; }
  .category-schule { --category: #18795e; --category-ink: #123c30; --category-soft: #91d0b5; --category-border: #3e9a78; --category-container: #e7f5ef; --category-done: #d9ebe3; --category-done-border: #b4d2c5; }
  .category-uni { --category: #236fae; --category-ink: #123b63; --category-soft: #96c3ef; --category-border: #4489c7; --category-container: #e8f2fb; --category-done: #dce9f5; --category-done-border: #b7cde0; }
  .sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .skip-link { position: fixed; z-index: 100; top: -100px; left: 12px; padding: 12px 20px; background: white; }
  .skip-link:focus { top: 12px; }
  .muted { color: var(--muted); }
}
@layer layout {
  .topbar { min-height: 50px; padding: 6px clamp(16px, 2vw, 32px); border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: flex-end; background: #fff; position: sticky; top: 0; z-index: 8; }
  main { width: 100%; max-width: 1920px; margin: 0 auto; padding: 16px clamp(16px, 2vw, 34px) 28px; outline: none; }
  .section-heading, .section-title { display: flex; align-items: center; }
  .section-heading { justify-content: space-between; gap: 8px; margin-bottom: 7px; }
  .section-title { gap: 7px; }
  .section-icon { display: grid; place-items: center; color: var(--blue); width: 24px; height: 24px; }
  .section-icon svg { width: 17px; height: 17px; }
  .next-section { background: #fff; border: 1px solid #d9e0ea; border-radius: 12px; box-shadow: 0 3px 12px #2632460a; padding: 10px 12px 12px; margin-bottom: 12px; }
  .task-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 5px; }
  .task-list[data-group='next'] { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; gap: 5px 12px; }
  .category-board { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); align-items: stretch; gap: 12px; }
  .category-column { min-width: 0; display: flex; flex-direction: column; background: var(--category-container); border: 1px solid var(--category-border); border-top: 4px solid var(--category); border-radius: 11px; padding: 6px 7px 7px; }
  .column-heading { display: flex; align-items: center; gap: 7px; min-height: 32px; margin-bottom: 4px; padding: 0 1px; }
  .column-heading h2 { color: var(--category-ink); }
  .column-swatch { width: 12px; height: 12px; border-radius: 4px; background: var(--category); border: 1px solid #0001; }
  .column-add { margin-left: auto; font-size: 1.2rem; }
  .category-column .count-pill { background: #ffffffb8; color: var(--category-ink); }
  .category-column .column-add { color: var(--category-ink); }
  .column-empty { font-size: .8125rem; color: var(--category-ink); padding: 10px 12px; border: 1px dashed var(--category-border); border-radius: 8px; background: #ffffff55; }
  .single-category { grid-template-columns: minmax(0, 780px); }
  .next-empty { padding: 10px 12px; background: #eef2fa; color: #748098; font-size: .8125rem; border-radius: 8px; }
}
@layer components {
  .primary, .secondary, .danger { border: 0; border-radius: 8px; padding: 8px 13px; min-height: 38px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; font-size: .875rem; font-weight: 600; }
  .primary { background: var(--blue); color: white; box-shadow: 0 3px 6px #3158ce12; }
  .primary:hover { background: #2548b5; }
  .primary > span { font-size: 1.15rem; line-height: 1; }
  .mobile-add { display: none; }
  .secondary { background: #eef1f7; color: #536078; }
  .secondary:hover { background: #e2e7f1; }
  .danger { background: #bc3a4b; color: white; }
  .text-button { border: 0; background: transparent; color: #5e6e8a; font-size: .8125rem; min-height: 36px; padding: 0 8px; border-radius: 7px; }
  .text-button:hover { background: #edf1f8; color: var(--blue); }
  .text-button.destructive { color: #b73b4d; margin-right: auto; padding: 0; }
  .icon-button { display: grid; place-items: center; border: 0; background: transparent; color: #647089; min-width: 40px; min-height: 40px; border-radius: 7px; }
  .icon-button:hover { background: #e9eef7; color: #334665; }
  .count-pill { min-width: 22px; height: 22px; border-radius: 6px; background: #e7edf9; color: #526991; font-size: .75rem; display: inline-grid; place-items: center; padding: 0 6px; font-weight: 500; }
  .count-pill.neutral { background: #edf0f5; color: #6c788c; }
  .task-row { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto 40px; align-items: center; column-gap: 2px; min-height: 52px; padding: 3px 4px 3px 2px; border: 1px solid var(--category-border); border-radius: 8px; background: var(--category-soft); color: var(--category-ink); position: relative; }
  .task-content { grid-column: 2; grid-row: 1; min-width: 0; display: flex; align-items: center; gap: 7px; padding: 0 4px; }
  .task-title { min-width: 0; font-size: .9375rem; line-height: 1.25; font-weight: 550; display: block; overflow-wrap: anywhere; }
  .task-meta { display: flex; align-items: center; flex: 0 0 auto; gap: 6px; margin: 0; }
  .drag-handle { grid-column: 4; grid-row: 1; align-self: center; display: grid; place-items: center; color: var(--category-ink); opacity: .76; background: transparent; border: 0; padding: 0; min-width: 40px; min-height: 44px; border-radius: 7px; touch-action: none; cursor: grab; }
  .drag-handle:hover, .drag-handle:focus-visible { opacity: 1; background: #ffffff55; }
  .complete-button { grid-column: 1; grid-row: 1; align-self: center; width: 40px; height: 44px; min-width: 40px; border: 0; background: transparent; padding: 9px; display: grid; place-items: center; position: relative; border-radius: 50%; color: var(--category-ink); }
  .complete-button::before { content: ''; border: 1.5px solid var(--category); border-radius: 50%; width: 21px; height: 21px; position: absolute; background: #ffffff45; }
  .complete-button svg { width: 16px; height: 16px; opacity: 0; position: relative; }
  .complete-button:hover { background: #ffffff65; }
  .complete-button:hover svg { opacity: 1; }
  .repeat-marker { color: var(--category-ink); }
  .repeat-marker svg { width: 15px; height: 15px; }
  .task-actions { grid-column: 3; grid-row: 1; display: flex; align-items: center; gap: 0; }
  .task-actions .icon-button { color: var(--category-ink); }
  .task-actions .icon-button:hover { background: #ffffff66; }
  .importance-button.active { color: #795613; }
  .importance-button.active svg { fill: #ffefaa; }
  .next-button { border: 0; background: transparent; color: var(--category-ink); border-radius: 7px; min-height: 40px; min-width: 40px; display: grid; place-items: center; padding: 0; }
  .next-button svg { width: 17px; height: 17px; }
  .next-button:hover { background: #ffffffa6; }
  .next-button.is-next { background: transparent; }
  .next-button.is-next:hover { background: #ffffff65; }
  .history-section { border-top: 1px solid var(--line); padding-top: 5px; margin-top: 13px; }
  .history-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
  .history-toggle { display: flex; gap: 7px; align-items: center; background: none; border: 0; min-height: 40px; padding: 0 2px; color: #6c788b; text-align: left; }
  .history-title { font-size: 1rem; font-weight: 600; }
  .history-chevron { transition: transform .15s; }
  .history-chevron svg { width: 17px; height: 17px; }
  .history-chevron.expanded { transform: rotate(90deg); }
  .today-count { display: flex; gap: 6px; align-items: center; color: #557567; font-size: .8125rem; }
  .today-count svg { width: 17px; height: 17px; }
  .completed-list { margin-top: 5px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px 12px; }
  .is-completed { grid-template-columns: 36px minmax(0, 1fr) 40px; min-height: 48px; padding: 2px 4px; column-gap: 2px; background: var(--category-done); border-color: var(--category-done-border); }
  .is-completed .task-content { padding: 0 4px; }
  .is-completed .task-title { text-decoration: line-through; color: #727887; font-weight: 400; font-size: .9375rem; }
  .is-completed .task-actions { grid-column: 3; grid-row: 1; }
  .completion-mark { grid-column: 1; grid-row: 1; width: 32px; min-width: 32px; height: 32px; background: #ffffff75; color: var(--category-ink); border-radius: 50%; display: grid; place-items: center; }
  .completion-mark svg { width: 17px; height: 17px; }
  .task-meta time { font-size: .75rem; color: #757f8e; }
  .task-actions .delete-button:hover { color: #b6374a; background: #fff8; }
  .history-empty { padding: 12px 0; color: #7c8799; font-size: .875rem; }
  dialog { border: 1px solid #e4e8f1; padding: 28px; border-radius: 18px; width: min(510px, calc(100% - 28px)); max-height: calc(100dvh - 32px); overflow: auto; background: white; color: #263246; box-shadow: 0 25px 90px #1c2c502b; }
  dialog::backdrop { background: #17244065; backdrop-filter: blur(3px); }
  .dialog-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; margin-bottom: 25px; }
  .dialog-heading h2 { font-size: 1.5rem; }
  .close-dialog.icon-button { font-size: 1.6rem; margin-top: -8px; margin-right: -9px; }
  .field-label, legend { font-size: .875rem; font-weight: 600; }
  input[type='text'] { border: 1px solid #dbe0eb; border-radius: 8px; width: 100%; padding: 12px; margin: 8px 0 20px; color: #26314b; font-size: 1rem; }
  input[type='text']::placeholder { color: #8490a5; font-size: .875rem; }
  .category-picker { border: 0; margin: 0 0 23px; padding: 0; }
  legend { margin-bottom: 9px; }
  legend span { color: #7b8698; font-size: .75rem; font-weight: 400; }
  #category-options { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
  .category-choice { position: relative; cursor: pointer; }
  .category-choice > span { display: flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid var(--line); border-radius: 8px; min-height: 44px; font-size: .875rem; color: #637086; }
  .category-choice input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
  .category-choice input:checked + span { background: var(--category-soft); border-color: var(--category); color: var(--category-ink); }
  .category-choice input:focus-visible + span { outline: 3px solid #3158ce; outline-offset: 3px; }
  .category-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--category); display: inline-block; }
  .form-toggles { border-top: 1px solid var(--line); }
  .toggle-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 75px; padding: 12px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
  .toggle-row strong { display: block; font-size: .875rem; font-weight: 600; }
  .toggle-row small { display: block; color: #748097; font-size: .75rem; margin-top: 2px; }
  input[role='switch'] { appearance: none; width: 40px; min-width: 40px; height: 24px; border-radius: 20px; background: #dce1ec; position: relative; cursor: pointer; margin: 10px 0 10px 4px; transition: background .15s; }
  input[role='switch']::before { content: ''; background: white; width: 18px; height: 18px; position: absolute; border-radius: 50%; top: 3px; left: 3px; box-shadow: 0 1px 3px #0002; transition: transform .15s; }
  input[role='switch']:checked { background: var(--blue); }
  input[role='switch']:checked::before { transform: translateX(16px); }
  .dialog-footer { display: flex; justify-content: flex-end; align-items: center; gap: 10px; margin-top: 25px; flex-wrap: wrap; }
  #delete-dialog { max-width: 430px; }
  #delete-dialog h2 { font-size: 1.4rem; margin-bottom: 12px; }
  #delete-description { overflow-wrap: anywhere; margin-bottom: 8px; }
  #delete-dialog .muted { font-size: .875rem; }
  .delete-symbol { width: 42px; height: 42px; background: #fbeff1; color: #bc3a4b; border-radius: 12px; font-size: 2rem; line-height: 1; display: grid; place-items: center; margin-bottom: 17px; }
  .inline-error { padding: 10px 0 0; color: #b23d50; font-size: .875rem; }
  .toast { position: fixed; bottom: 28px; left: 50%; transform: translate(-50%, 12px); z-index: 50; padding: 13px 20px; background: #26374f; color: white; border-radius: 11px; box-shadow: 0 7px 20px #20324a20; opacity: 0; pointer-events: none; transition: .2s; font-size: .875rem; max-width: calc(100% - 28px); width: max-content; }
  .toast.visible { opacity: 1; transform: translate(-50%, 0); }
  .toast.error { background: #a7384b; }
  .loading, .load-error { padding: 35px 0; }
  .load-error p { margin: 20px 0; }
  .task-row.dragging { border-color: var(--category); outline: 2px solid var(--category); outline-offset: 2px; box-shadow: 0 7px 20px #263f7420; z-index: 2; }
  .just-completed { animation: completed-flash .7s ease-out; }
  @keyframes completed-flash { from { box-shadow: 0 0 0 3px var(--category-border); } to { box-shadow: 0 0 0 0 transparent; } }
  body.is-dragging { cursor: grabbing; user-select: none; }
  body.is-dragging .drag-handle { cursor: grabbing; }
}
@layer responsive {
  @media (max-width: 1179px) {
    .category-board { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .single-category { grid-template-columns: minmax(0, 780px); }
    .task-row { grid-template-columns: 40px minmax(0, 1fr) auto 40px; }
    .is-completed { grid-template-columns: 36px minmax(0, 1fr) 40px; }
  }
  @media (max-width: 759px) {
    .topbar { min-height: 48px; padding: 5px 12px; }
    .topbar > .new-task { padding-inline: 11px; }
    main { padding: 12px 12px 86px; }
    h1 { font-size: 1.2rem; }
    .section-heading { margin-bottom: 6px; gap: 7px; }
    .section-title { gap: 7px; }
    .section-icon { width: 22px; height: 22px; }
    .section-heading .text-button { padding-inline: 3px; font-size: .8125rem; }
    .category-board, .task-list[data-group='next'], .completed-list { grid-template-columns: minmax(0, 1fr); }
    .category-board { row-gap: 10px; }
    .next-section { padding: 9px 10px 10px; margin-bottom: 8px; }
    .task-row { min-height: 56px; grid-template-columns: 42px minmax(0, 1fr) auto 42px; padding-block: 4px; }
    .complete-button, .drag-handle { min-width: 42px; width: 42px; min-height: 46px; }
    .icon-button, .next-button { min-width: 42px; min-height: 42px; }
    .column-heading { margin-bottom: 3px; }
    .column-empty { padding: 9px 12px; }
    .is-completed { min-height: 52px; grid-template-columns: 36px minmax(0, 1fr) 42px; }
    .history-section { margin-top: 11px; }
    .mobile-add { display: grid; position: fixed; right: 14px; bottom: calc(14px + env(safe-area-inset-bottom)); width: 50px; height: 50px; font-size: 1.75rem; border-radius: 15px; box-shadow: 0 5px 18px #3158ce3b; z-index: 9; padding: 0; }
    .toast { bottom: calc(76px + env(safe-area-inset-bottom)); }
  }
  @media (max-width: 390px) {
    main, .topbar { padding-inline: 12px; }
    .section-icon { display: none; }
    .task-row { grid-template-columns: 40px minmax(0, 1fr) auto 40px; }
    .complete-button, .drag-handle { min-width: 40px; width: 40px; }
    .icon-button, .next-button { min-width: 40px; }
    dialog { padding: 20px; }
    #category-options { gap: 5px; }
    .category-choice > span { gap: 4px; }
    .dialog-footer { gap: 7px; }
  }
  @media (prefers-reduced-motion: reduce) { *, *::before { scroll-behavior: auto !important; transition: none !important; animation: none !important; } }
}
