:root {
    color-scheme: light;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: #1f2937;
    background: #f3f4f6;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
}

[hidden] {
    display: none !important;
}

.auth-page {
    width: min(100% - 2rem, 52rem);
    margin: 0 auto;
    padding: 3rem 0;
}

.page-header {
    margin-bottom: 1.5rem;
}

.page-header h1 {
    margin: 0.25rem 0 0.75rem;
    color: #111827;
    font-size: clamp(1.8rem, 5vw, 2.5rem);
}

.page-header p {
    margin: 0;
    line-height: 1.6;
}

.eyebrow {
    color: #4f46e5;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.status-panel,
.panel {
    padding: 1.5rem;
    border: 1px solid #d1d5db;
    border-radius: 0.75rem;
    background: #ffffff;
    box-shadow: 0 0.25rem 1rem rgb(17 24 39 / 6%);
}

.status-panel {
    margin-bottom: 1rem;
    color: #374151;
}

.status-panel p,
.panel p {
    margin: 0;
    line-height: 1.5;
}

.status-panel[data-state="authenticated"] {
    border-color: #86efac;
    background: #f0fdf4;
}

.status-panel[data-state="configuration-error"],
.status-panel[data-state="api-error"] {
    border-color: #fca5a5;
    background: #fef2f2;
}

.panel + .panel {
    margin-top: 1rem;
}

.panel h2 {
    margin: 0 0 0.75rem;
    color: #111827;
    font-size: 1.25rem;
}

.google-sign-in {
    min-height: 2.5rem;
    margin-top: 1.25rem;
}

.profile-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
    gap: 1rem;
    margin: 1.5rem 0 0;
}

.profile-grid div {
    padding: 0.9rem;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    background: #f9fafb;
}

.profile-grid dt {
    color: #6b7280;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.profile-grid dd {
    margin: 0.35rem 0 0;
    overflow-wrap: anywhere;
}

.error-panel {
    border-color: #fca5a5;
    background: #fef2f2;
}

button {
    margin-top: 1.25rem;
    padding: 0.65rem 1rem;
    border: 0;
    border-radius: 0.4rem;
    color: #ffffff;
    background: #4f46e5;
    cursor: pointer;
    font: inherit;
    font-weight: 600;
}

button:hover {
    background: #4338ca;
}

button:focus-visible {
    outline: 0.2rem solid #a5b4fc;
    outline-offset: 0.15rem;
}

.workspace-header,
.section-heading,
.attachment-list-item,
.note-list-item {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}

.workspace-header {
    align-items: center;
}

.workspace-header h2,
.section-heading h3,
.topic-column > h3,
.stacked-form h3,
.notes-section h3,
.attachments-section h3 {
    margin: 0 0 0.75rem;
    color: #111827;
}

.workspace-header p,
.section-heading p,
.notes-section > p,
.attachments-section > p {
    margin: 0;
    color: #6b7280;
}

.workspace-grid {
    display: grid;
    grid-template-columns: minmax(12rem, 0.8fr) minmax(18rem, 1.4fr);
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.topic-column,
.topic-detail-column {
    min-width: 0;
}

.topic-list,
.attachment-list,
.note-list {
    display: grid;
    gap: 0.6rem;
    padding: 0;
    margin: 0;
    list-style: none;
}

.topic-list-item {
    display: grid;
    width: 100%;
    margin: 0;
    padding: 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    color: #1f2937;
    background: #ffffff;
    text-align: left;
}

.topic-list-item:hover,
.topic-list-item.selected {
    border-color: #4f46e5;
    background: #eef2ff;
}

.topic-list-item span,
.topic-list-item small,
.attachment-list-item span,
.attachment-list-item small,
.note-list-item span,
.note-list-item small {
    display: block;
    margin-top: 0.25rem;
    color: #6b7280;
    font-size: 0.85rem;
    font-weight: 400;
    overflow-wrap: anywhere;
}

.stacked-form {
    display: grid;
    gap: 0.55rem;
    margin-top: 1.5rem;
}

.stacked-form label,
.attachment-form label {
    color: #374151;
    font-size: 0.9rem;
    font-weight: 600;
}

input[type="text"],
textarea,
input[type="file"] {
    width: 100%;
    padding: 0.6rem;
    border: 1px solid #9ca3af;
    border-radius: 0.4rem;
    color: #1f2937;
    background: #ffffff;
    font: inherit;
}

textarea {
    resize: vertical;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.checkbox-label input {
    width: auto;
}

.secondary-button {
    margin-top: 0;
    color: #374151;
    background: #e5e7eb;
}

.secondary-button:hover {
    background: #d1d5db;
}

.inline-error {
    margin: 1rem 0 0;
    padding: 0.75rem;
    border: 1px solid #fca5a5;
    border-radius: 0.4rem;
    color: #991b1b;
    background: #fef2f2;
}

.empty-message {
    color: #6b7280;
}

.recap-section,
.notes-section,
.attachments-section {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid #e5e7eb;
}

.recap-content {
    margin-top: 1rem;
    padding: 1rem;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    background: #f9fafb;
}

.recap-summary {
    margin: 0;
    color: #374151;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.recap-key-points-heading {
    margin: 1rem 0 0.5rem;
}

.recap-key-points {
    margin: 0;
    padding-left: 1.25rem;
    color: #374151;
}

.attachment-form {
    display: grid;
    gap: 0.55rem;
    margin: 1rem 0 1.25rem;
}

.attachment-list-item {
    align-items: center;
    padding: 0.75rem;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    background: #f9fafb;
}

.note-list-item {
    align-items: flex-start;
    padding: 0.75rem;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    background: #f9fafb;
}

.note-details {
    min-width: 0;
}

.note-details p {
    margin: 0.5rem 0 0;
    color: #374151;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.attachment-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.5rem;
}

.note-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.5rem;
}

.attachment-actions button,
.note-actions button {
    margin-top: 0;
    padding: 0.45rem 0.7rem;
    font-size: 0.9rem;
}

.danger-button {
    background: #b91c1c;
}

.danger-button:hover {
    background: #991b1b;
}

.login-page {
    width: min(100% - 2rem, 34rem);
    padding-top: clamp(3rem, 12vh, 8rem);
}

.app-page {
    min-height: 100vh;
}

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    padding: 1rem max(1rem, calc((100% - 76rem) / 2));
    border-bottom: 1px solid #e5e7eb;
    background: #ffffff;
}

.app-brand {
    color: #111827;
    font-size: 1.25rem;
    font-weight: 800;
    text-decoration: none;
}

.app-brand:focus-visible,
.app-nav a:focus-visible {
    outline: 0.2rem solid #a5b4fc;
    outline-offset: 0.15rem;
    border-radius: 0.2rem;
}

.app-nav {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.75rem;
}

.app-nav a {
    padding: 0.35rem 0.45rem;
    color: #4b5563;
    font-size: 0.92rem;
    font-weight: 600;
    text-decoration: none;
}

.app-nav a:hover,
.app-nav a.active {
    color: #4338ca;
}

.current-user-label {
    max-width: 14rem;
    color: #6b7280;
    font-size: 0.85rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.app-nav button {
    margin-top: 0;
    padding: 0.45rem 0.7rem;
    font-size: 0.9rem;
}

.app-main {
    width: min(100% - 2rem, 76rem);
    margin: 0 auto;
    padding: 2rem 0 4rem;
}

.page-panel {
    padding: clamp(1rem, 3vw, 2rem);
    border: 1px solid #d1d5db;
    border-radius: 0.75rem;
    background: #ffffff;
    box-shadow: 0 0.25rem 1rem rgb(17 24 39 / 6%);
}

.page-panel .page-header {
    margin-bottom: 1.5rem;
}

.dashboard-toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.dashboard-toolbar label {
    color: #374151;
    font-weight: 600;
}

.dashboard-toolbar select {
    width: auto;
    min-width: 10rem;
}

.topic-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr));
    gap: 1rem;
}

.topic-card {
    display: flex;
    flex-direction: column;
    min-width: 0;
    padding: 1rem;
    border: 1px solid #d1d5db;
    border-radius: 0.65rem;
    background: #f9fafb;
}

.topic-card h2 {
    margin: 0;
    font-size: 1.2rem;
}

.topic-card h2 a {
    color: #312e81;
}

.topic-card-description {
    min-height: 3rem;
    color: #4b5563;
}

.topic-card-details {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.35rem 1rem;
    margin: 0 0 1rem;
    font-size: 0.9rem;
}

.topic-card-details dt {
    color: #6b7280;
    font-weight: 600;
}

.topic-card-details dd {
    margin: 0;
    color: #1f2937;
}

.card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-top: auto;
}

.card-actions button {
    margin-top: 0;
}

.topic-edit-form {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #d1d5db;
}

.create-topic-form {
    max-width: 36rem;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid #e5e7eb;
}

.create-topic-form h2 {
    margin-top: 0;
}

.chat-panel {
    margin-top: 1rem;
}

.chat-panel .section-heading {
    margin-bottom: 1rem;
}

.chat-panel .section-heading h2 {
    margin: 0.25rem 0 0.5rem;
}

.chat-panel .section-heading p:last-child {
    color: #6b7280;
}

.chat-status {
    min-height: 1.5rem;
    margin: 0 0 0.75rem;
    color: #4b5563;
    font-size: 0.9rem;
}

.chat-message-log {
    display: grid;
    gap: 0.75rem;
    max-height: 32rem;
    overflow-y: auto;
    padding: 1rem;
    border: 1px solid #e5e7eb;
    border-radius: 0.6rem;
    background: #f9fafb;
}

.chat-message {
    max-width: min(90%, 48rem);
    padding: 0.8rem 1rem;
    border: 1px solid #d1d5db;
    border-radius: 0.6rem;
    background: #ffffff;
}

.chat-message-user {
    justify-self: end;
    border-color: #c7d2fe;
    background: #eef2ff;
}

.chat-message-author {
    margin: 0;
    color: #3730a3;
    font-size: 0.85rem;
}

.chat-message-content {
    margin: 0.4rem 0 0;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.chat-plan-summary {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid #e5e7eb;
}

.chat-plan-status {
    margin: 0;
    color: #3730a3;
    font-size: 0.82rem;
    font-weight: 700;
    text-transform: uppercase;
}

.chat-plan-status-executed {
    color: #166534;
}

.chat-plan-status-failed,
.chat-plan-status-cancelled,
.chat-plan-status-clarification_required {
    color: #991b1b;
}

.chat-action-list {
    display: grid;
    gap: 0.25rem;
    margin: 0.5rem 0 0;
    padding-left: 1.25rem;
    color: #374151;
    font-size: 0.9rem;
}

.chat-plan-error {
    margin: 0.5rem 0 0;
    color: #991b1b;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.chat-pending-plans {
    margin-top: 1rem;
    padding: 1rem;
    border: 1px solid #fbbf24;
    border-radius: 0.6rem;
    background: #fffbeb;
}

.chat-pending-plans h3 {
    margin: 0;
    color: #92400e;
}

.chat-pending-plan + .chat-pending-plan {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #fcd34d;
}

.chat-plan-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-top: 0.75rem;
}

.chat-plan-controls button {
    margin-top: 0;
}

.chat-composer {
    max-width: 48rem;
    margin-top: 1.25rem;
}

.chat-composer textarea {
    margin-top: 0.35rem;
}

.chat-composer button {
    margin-top: 0.75rem;
}

.form-help {
    margin: 0.35rem 0 0;
    color: #6b7280;
    font-size: 0.85rem;
}

.topic-metadata-form {
    max-width: 42rem;
    margin-bottom: 2rem;
}

.item-form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr));
    gap: 1rem;
}

.item-form,
.item-edit-form {
    padding: 1rem;
    border: 1px solid #e5e7eb;
    border-radius: 0.6rem;
    background: #f9fafb;
}

.item-form h3,
.item-edit-form h4 {
    margin-top: 0;
}

.recap-section,
.item-create-section,
.items-section {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid #e5e7eb;
}

.recap-section h2,
.item-create-section h2,
.items-section h2 {
    margin: 0 0 0.75rem;
    color: #111827;
}

.recap-summary,
.preserve-lines {
    white-space: pre-wrap;
}

.recap-key-points {
    padding-left: 1.25rem;
}

.item-list {
    display: grid;
    gap: 1rem;
}

.item-card {
    padding: 1rem;
    border: 1px solid #d1d5db;
    border-radius: 0.65rem;
    background: #ffffff;
}

.item-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.item-card-header h3 {
    margin: 0;
    overflow-wrap: anywhere;
}

.type-badge,
.processing-status,
.muted-label {
    color: #6b7280;
    font-size: 0.82rem;
    font-weight: 700;
}

.type-badge {
    padding: 0.25rem 0.5rem;
    border-radius: 999px;
    color: #3730a3;
    background: #e0e7ff;
    white-space: nowrap;
}

.processing-status {
    margin: 0.65rem 0;
}

.status-failed {
    color: #b91c1c;
}

.status-completed {
    color: #15803d;
}

.item-fields {
    display: grid;
    grid-template-columns: minmax(6rem, auto) 1fr;
    gap: 0.4rem 1rem;
    margin: 0 0 1rem;
}

.item-fields dt {
    color: #6b7280;
    font-weight: 600;
}

.item-fields dd {
    min-width: 0;
    margin: 0;
    overflow-wrap: anywhere;
}

.item-attachments {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #e5e7eb;
}

.item-attachments h4 {
    margin: 0 0 0.75rem;
}

.attachment-list-item {
    flex-wrap: wrap;
    padding: 0.6rem;
    border: 1px solid #e5e7eb;
    border-radius: 0.45rem;
    background: #f9fafb;
}

.attachment-list-item > span {
    overflow-wrap: anywhere;
    font-weight: 600;
}

.attachment-list-item small {
    color: #6b7280;
}

.attachment-upload-form,
.attachment-replacement-form {
    display: flex;
    align-items: flex-end;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-top: 0.75rem;
}

.attachment-upload-form label,
.attachment-replacement-form label {
    flex: 1 1 14rem;
}

.attachment-upload-form button,
.attachment-replacement-form button {
    margin-top: 0;
}

.account-section + .account-section {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid #e5e7eb;
}

.account-section h2 {
    margin-top: 0;
}

.preferences-form {
    max-width: 34rem;
}

.chat-preference-section {
    margin-top: 1rem;
    padding: 1rem;
    border: 1px solid #e5e7eb;
    border-radius: 0.6rem;
    background: #f9fafb;
}

.chat-preference-section h3 {
    margin: 0 0 0.5rem;
    color: #111827;
}

.chat-preference-section p {
    color: #4b5563;
}

.warning-message {
    margin: 0.75rem 0 0;
    color: #92400e !important;
    font-size: 0.88rem;
}

.source-link {
    display: inline-block;
    margin-bottom: 0.75rem;
    color: #4338ca;
    font-weight: 600;
}

.agenda-filters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 10rem), 1fr));
    align-items: end;
    gap: 0.8rem;
    margin-bottom: 1.5rem;
    padding: 1rem;
    border: 1px solid #e5e7eb;
    border-radius: 0.6rem;
    background: #f9fafb;
}

.agenda-filters label {
    display: block;
    margin-bottom: 0.35rem;
    color: #374151;
    font-size: 0.9rem;
    font-weight: 600;
}

.agenda-filters button {
    margin-top: 0;
}

.agenda-list {
    display: grid;
    gap: 1rem;
}

.agenda-card {
    padding: 1rem;
    border: 1px solid #d1d5db;
    border-radius: 0.65rem;
    background: #ffffff;
}

.agenda-card h2 {
    margin: 0;
    overflow-wrap: anywhere;
}

.agenda-card.focused {
    border-color: #4f46e5;
    box-shadow: 0 0 0 0.2rem #e0e7ff;
}

.agenda-status-completed {
    color: #166534;
    background: #dcfce7;
}

.agenda-status-dismissed {
    color: #991b1b;
    background: #fee2e2;
}

.agenda-view-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-bottom: 1rem;
}

.agenda-view-controls button[aria-pressed="true"] {
    border-color: #4338ca;
    color: #ffffff;
    background: #4338ca;
}

.agenda-calendar-view {
    margin-top: 1rem;
}

.calendar-toolbar {
    display: grid;
    grid-template-columns: auto minmax(10rem, 1fr) auto auto;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.calendar-toolbar h2 {
    margin: 0;
    color: #111827;
    font-size: 1.35rem;
    text-align: center;
}

.agenda-calendar {
    overflow-x: auto;
    padding-bottom: 0.25rem;
}

.calendar-weekdays,
.calendar-grid {
    min-width: 44rem;
}

.calendar-weekdays {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 0.35rem;
    margin-bottom: 0.35rem;
}

.calendar-weekdays span {
    padding: 0.45rem 0.5rem;
    color: #4b5563;
    font-size: 0.8rem;
    font-weight: 700;
    text-align: center;
    text-transform: uppercase;
}

.calendar-grid {
    display: grid;
    gap: 0.35rem;
}

.calendar-week {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 0.35rem;
}

.calendar-day {
    min-height: 9rem;
    min-width: 0;
    padding: 0.5rem;
    border: 1px solid #d1d5db;
    border-radius: 0.55rem;
    background: #ffffff;
}

.calendar-day-empty {
    border-style: dashed;
    background: #f9fafb;
}

.calendar-day.is-today {
    border-color: #4f46e5;
    background: #eef2ff;
    box-shadow: 0 0 0 0.1rem #c7d2fe;
}

.calendar-day-number {
    display: block;
    margin-bottom: 0.45rem;
    color: #374151;
    font-weight: 700;
}

.calendar-day.is-today .calendar-day-number {
    color: #3730a3;
}

.calendar-day-items,
.agenda-unscheduled-list {
    display: grid;
    gap: 0.5rem;
}

.calendar-agenda-card {
    padding: 0.55rem;
    border-color: #c7d2fe;
}

.calendar-agenda-card .item-card-header {
    align-items: flex-start;
    gap: 0.35rem;
}

.calendar-agenda-card .item-card-header h2 {
    font-size: 0.9rem;
    line-height: 1.25;
}

.calendar-agenda-card .type-badge {
    flex-shrink: 0;
    padding: 0.15rem 0.35rem;
    font-size: 0.7rem;
}

.calendar-item-due {
    margin: 0.35rem 0;
    color: #4b5563;
    font-size: 0.8rem;
    font-weight: 600;
}

.calendar-item-description {
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    font-size: 0.82rem;
}

.calendar-agenda-card .source-link {
    margin-bottom: 0.5rem;
    font-size: 0.85rem;
}

.calendar-agenda-card .card-actions {
    gap: 0.35rem;
    margin-top: 0.5rem;
}

.calendar-agenda-card .card-actions button {
    padding: 0.4rem 0.55rem;
    font-size: 0.8rem;
}

.agenda-unscheduled {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid #e5e7eb;
}

.agenda-unscheduled h2 {
    margin: 0 0 0.75rem;
    color: #111827;
    font-size: 1.1rem;
}

.related-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 0.75rem;
}

.related-links a {
    color: #4338ca;
    font-weight: 600;
}

.related-links span {
    color: #6b7280;
    font-size: 0.85rem;
}

.agenda-edit-form {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #e5e7eb;
}

input:not([type="checkbox"]):not([type="radio"]),
select {
    width: 100%;
    padding: 0.6rem;
    border: 1px solid #9ca3af;
    border-radius: 0.4rem;
    color: #1f2937;
    background: #ffffff;
    font: inherit;
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible,
button:focus-visible {
    outline: 0.2rem solid #a5b4fc;
    outline-offset: 0.15rem;
}

@media (max-width: 42rem) {
    .calendar-toolbar {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .calendar-toolbar h2 {
        grid-column: 1 / -1;
        grid-row: 1;
    }
}

@media (max-width: 42rem) {
    .app-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .app-nav {
        justify-content: flex-start;
    }

    .workspace-grid {
        grid-template-columns: 1fr;
    }

    .workspace-header,
    .section-heading,
    .attachment-list-item,
    .note-list-item {
        align-items: stretch;
        flex-direction: column;
    }

    .workspace-header button {
        align-self: flex-start;
    }

    .section-heading button {
        align-self: flex-start;
    }
}