/*
 * TIMFIT UX refresh
 *
 * This layer intentionally leaves the original component structure intact.
 * It only improves hierarchy, readability, touch targets and responsive flow.
 */

:root {
  --bg: #090909;
  --bg-soft: #10100f;
  --surface: rgba(20, 20, 19, 0.96);
  --surface-strong: rgba(27, 27, 25, 0.98);
  --surface-alt: rgba(32, 31, 29, 0.96);
  --line: rgba(255, 255, 255, 0.1);
  --line-strong: rgba(180, 155, 110, 0.32);
  --text: #faf8f2;
  --text-main: #faf8f2;
  --text-soft: rgba(250, 248, 242, 0.78);
  --muted: rgba(250, 248, 242, 0.56);
  --gold: #b49b6e;
  --gold-bright: #ceb887;
  --gold-soft: rgba(180, 155, 110, 0.14);
  --success: #9ed48a;
  --danger: #ef8585;
  --shadow: 0 20px 52px rgba(0, 0, 0, 0.28);
  --radius-xl: 24px;
  --radius-lg: 18px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --page-gutter: clamp(0.8rem, 2vw, 1.4rem);
}

html {
  background: #090909;
  color-scheme: dark;
  overflow-x: hidden;
  scroll-behavior: smooth;
}

body {
  width: 100%;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 14% -8%, rgba(180, 155, 110, 0.12), transparent 28rem),
    radial-gradient(circle at 92% 12%, rgba(255, 255, 255, 0.045), transparent 24rem),
    #090909;
  font-size: 15px;
  line-height: 1.5;
  letter-spacing: 0;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection {
  color: #090909;
  background: var(--gold-bright);
}

button,
input,
select,
textarea {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible,
label:focus-within {
  outline: 3px solid rgba(206, 184, 135, 0.45);
  outline-offset: 2px;
}

.app-shell--focused {
  width: 100%;
  max-width: 1600px;
  min-width: 0;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top, 0px) + 0.85rem) var(--page-gutter)
    calc(env(safe-area-inset-bottom, 0px) + 1.5rem);
}

.panel,
.section-card,
.day-column,
.video-card,
.video-tile,
.request-card,
.mini-card,
.quiz-score-card {
  box-shadow: 0 16px 42px rgba(0, 0, 0, 0.18);
}

.section-card {
  padding: clamp(1rem, 2vw, 1.4rem);
  border-color: rgba(255, 255, 255, 0.09);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.025), transparent 9rem),
    rgba(22, 22, 21, 0.98);
}

.section-header {
  margin-bottom: 1.1rem;
}

.section-header h2,
.section-header h3,
.panel-title {
  letter-spacing: -0.035em;
}

.section-header p,
.panel-subtitle,
.preview-note,
.helper-text,
.field-hint {
  max-width: 72ch;
}

/* Header and primary navigation */
.topbar--planner {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.8rem;
  padding: 0.72rem 0.78rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  background: rgba(15, 15, 14, 0.9);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.16);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.topbar-primary--planner {
  display: flex;
  align-items: center;
  min-width: 0;
  justify-content: flex-start;
  gap: 0.8rem;
}

.planner-wordmark {
  flex: 0 0 auto;
  padding: 0.15rem 1rem 0.15rem 0.25rem;
  border-right: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-main);
  font-size: clamp(1.35rem, 2vw, 1.75rem);
  letter-spacing: 0.19em;
}

.topbar-tabs--planner {
  min-width: 0;
  flex-wrap: nowrap;
  justify-content: flex-start;
  gap: 0.35rem;
}

.tab-button {
  min-height: 42px;
  padding: 0.62rem 0.9rem;
  border-color: transparent;
  background: transparent;
  color: var(--text-soft);
  font-size: 0.88rem;
  transition: color 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}

.tab-button:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.05);
}

.tab-button--active {
  color: #fff8e8;
  border-color: rgba(180, 155, 110, 0.32);
  background: rgba(180, 155, 110, 0.16);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.top-actions--planner {
  min-width: 0;
  flex-wrap: nowrap;
  justify-content: flex-end;
  gap: 0.45rem;
}

.top-actions--planner .install-button,
.top-actions--planner .ghost-button {
  min-height: 42px;
  padding: 0.65rem 0.85rem;
  font-size: 0.82rem;
}

.topbar-session {
  min-width: 0;
  flex-wrap: nowrap;
  gap: 0.7rem;
  margin-left: 0.2rem;
  padding-left: 0.75rem;
  border-left: 1px solid rgba(255, 255, 255, 0.1);
}

.topbar-account-copy {
  max-width: 190px;
}

.topbar-account-label {
  font-size: 0.59rem;
}

.topbar-account-name {
  color: var(--text-main);
  font-size: 0.86rem;
}

.topbar-logout-button {
  min-height: 40px;
  padding: 0.45rem 0.65rem;
  border: 1px solid rgba(239, 133, 133, 0.16);
  background: rgba(239, 133, 133, 0.055);
  color: var(--danger);
  font-size: 0.78rem;
}

.topbar-logout-button:hover {
  border-color: rgba(239, 133, 133, 0.34);
  background: rgba(239, 133, 133, 0.11);
}

.notice {
  margin-bottom: 0.75rem;
  padding: 0.7rem 0.85rem;
  border-radius: 13px;
  color: var(--text-soft);
  font-size: 0.86rem;
}

/* Controls and forms */
.button,
.ghost-button,
.danger-button,
.install-button {
  min-height: 46px;
  border-radius: 13px;
}

.button {
  background: linear-gradient(135deg, #d1bd91, #ae9261);
  box-shadow: 0 10px 24px rgba(180, 155, 110, 0.15);
}

.ghost-button {
  border-color: rgba(255, 255, 255, 0.11);
  background: rgba(255, 255, 255, 0.035);
}

.field {
  min-width: 0;
}

.field label {
  color: rgba(250, 248, 242, 0.84);
  font-size: 0.82rem;
}

.field input,
.field select,
.field textarea,
.planner-client-select-wrap select {
  border-color: rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.045);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.025);
}

.field input:hover,
.field select:hover,
.field textarea:hover,
.planner-client-select-wrap select:hover {
  border-color: rgba(255, 255, 255, 0.2);
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.planner-client-select-wrap select:focus {
  border-color: rgba(180, 155, 110, 0.62);
  background: rgba(255, 255, 255, 0.065);
}

.field input[type="file"]::file-selector-button {
  margin-right: 0.75rem;
  padding: 0.55rem 0.7rem;
  border: 0;
  border-radius: 9px;
  background: rgba(180, 155, 110, 0.16);
  color: var(--gold-bright);
  font: inherit;
  font-weight: 700;
}

select option,
select optgroup {
  color: #111;
  background: #fff;
}

/* Planner */
.planner-stage--minimal {
  min-width: 0;
  gap: 0.75rem;
}

.planner-toolbar {
  min-width: 0;
  padding: 0.7rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 19px;
  background: rgba(18, 18, 17, 0.92);
}

.planner-toolbar-main {
  flex: 1 1 auto;
  min-width: 0;
}

.planner-toolbar-side {
  flex: 0 0 auto;
  min-width: 0;
}

.planner-client-picker--inline {
  flex: 0 0 220px;
  min-width: 170px;
  max-width: 240px;
}

.planner-client-select-wrap select {
  width: 100%;
  min-height: 42px;
  color: var(--text-main);
  font-size: 0.85rem;
  font-weight: 600;
}

.planner-legend--minimal {
  flex: 1 1 auto;
  min-width: 0;
}

.planner-legend-list--minimal {
  min-width: 0;
  flex-wrap: nowrap;
  gap: 0.4rem;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  scrollbar-width: none;
}

.planner-legend-list--minimal::-webkit-scrollbar,
.topbar-tabs--planner::-webkit-scrollbar,
.day-tabs::-webkit-scrollbar {
  display: none;
}

.legend-chip--minimal {
  flex: 0 0 auto;
  min-height: 40px;
  padding: 0.58rem 0.72rem;
  border-color: rgba(255, 255, 255, 0.13);
  background: rgba(255, 255, 255, 0.045);
  box-shadow: none;
  font-size: 0.82rem;
}

.legend-chip--minimal:hover {
  border-color: rgba(180, 155, 110, 0.38);
  background: rgba(180, 155, 110, 0.1);
}

.legend-chip--minimal .legend-chip__emoji {
  width: 1.35rem;
  height: 1.35rem;
  background: rgba(255, 255, 255, 0.08);
  font-size: 0.9rem;
}

.planner-import-button--minimal {
  flex: 0 0 auto;
  min-height: 40px;
  min-width: 76px;
  padding: 0.58rem 0.7rem;
  font-size: 0.8rem;
}

.planner-week-pill {
  min-height: 40px;
  padding: 0.6rem 0.8rem;
  border-color: rgba(180, 155, 110, 0.2);
  background: rgba(180, 155, 110, 0.08);
  color: var(--gold-bright);
  font-size: 0.8rem;
}

.planner-controls--minimal {
  flex-wrap: nowrap;
  gap: 0.35rem;
}

.planner-controls--minimal .ghost-button {
  min-height: 40px;
  padding: 0.58rem 0.7rem;
  font-size: 0.8rem;
}

.planner-grid--full {
  min-width: 0;
  gap: clamp(0.35rem, 0.7vw, 0.65rem);
}

.day-column--minimal {
  min-width: 0;
  min-height: clamp(500px, 70vh, 790px);
  gap: 0.55rem;
  padding: 0.72rem 0.62rem 0.62rem;
  border-radius: 19px;
  border-color: rgba(255, 255, 255, 0.09);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent 9rem),
    rgba(27, 27, 25, 0.98);
}

.day-column.is-today {
  border-color: rgba(180, 155, 110, 0.56);
  box-shadow: inset 0 0 0 1px rgba(180, 155, 110, 0.12), 0 16px 38px rgba(0, 0, 0, 0.22);
}

.day-header--minimal {
  min-height: 43px;
  align-items: flex-start;
}

.day-heading strong {
  color: var(--text-main);
  font-size: 0.88rem;
}

.day-heading span {
  font-size: 0.72rem;
}

.wake-chip {
  min-height: 32px;
  padding: 0.4rem 0.52rem;
}

.day-timeline {
  min-height: clamp(430px, 61vh, 680px);
  border-radius: 15px;
  border-color: rgba(255, 255, 255, 0.085);
  background: rgba(255, 255, 255, 0.025);
}

.timeline-marker {
  left: 0.38rem;
  right: 0.38rem;
}

.timeline-marker span {
  color: rgba(250, 248, 242, 0.52);
  font-size: 0.58rem;
}

.timeline-marker::after {
  left: 1.72rem;
  border-color: rgba(255, 255, 255, 0.075);
}

.timeline-now {
  left: 0.38rem;
  right: 0.38rem;
}

.timeline-now::before {
  left: 1.72rem;
  border-top-color: var(--gold-bright);
}

.timeline-now__label {
  min-height: 1.2rem;
  padding: 0.12rem 0.34rem;
  border-color: rgba(180, 155, 110, 0.48);
  color: #ffe7b5;
  font-size: 0.54rem;
}

.planner-item--timeline {
  border-left-width: 3px;
  border-radius: 10px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  -webkit-text-fill-color: currentColor;
}

.planner-item--timeline h4,
.planner-item--timeline p,
.planner-item--timeline .timeline-item__time {
  color: var(--text-main);
  -webkit-text-fill-color: currentColor;
}

.planner-drag-handle {
  background: rgba(8, 8, 8, 0.28);
}

.day-tabs {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  width: 100%;
  gap: 0.35rem;
  overflow: visible;
}

.day-tabs .chip {
  min-width: 0;
  min-height: 42px;
  padding: 0.45rem 0.2rem;
  font-size: 0.72rem;
}

/* Secondary workspaces */
.workspace-stack {
  width: min(1320px, 100%);
  min-width: 0;
  margin-inline: auto;
  gap: 0.9rem;
}

.video-library,
.video-library--documents,
.quiz-score-grid {
  grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr));
  gap: 0.75rem;
}

.video-card,
.video-tile,
.mini-card,
.quiz-score-card {
  border-radius: 17px;
  background: rgba(38, 37, 34, 0.78);
}

.video-card:hover,
.video-tile:hover,
.mini-card:hover {
  border-color: rgba(180, 155, 110, 0.28);
}

.tag {
  min-height: 25px;
  padding: 0.25rem 0.48rem;
  font-size: 0.68rem;
}

.empty-card,
.helper-panel {
  border-color: rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.025);
}

/* Modals, documents and quizzes */
.modal-backdrop {
  padding: clamp(0.65rem, 2vw, 1.25rem);
  background: rgba(0, 0, 0, 0.82);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.modal-card {
  border-radius: 22px;
  background: #11110f;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.55);
}

.planner-detail-highlight {
  border-radius: 18px;
  background: rgba(180, 155, 110, 0.11);
}

.planner-detail-highlight p {
  color: var(--text-main);
  font-size: clamp(0.95rem, 2vw, 1.05rem);
  line-height: 1.7;
}

.document-page-stack {
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: #0b0b0b;
}

.video-quiz-cue {
  border-radius: 13px;
  background: rgba(8, 8, 8, 0.92);
}

.quiz-modal-card,
.quiz-form,
.quiz-question,
.quiz-question-header,
.quiz-question-title,
.quiz-options,
.quiz-option,
.quiz-option span {
  min-width: 0;
  max-width: 100%;
  writing-mode: horizontal-tb !important;
  text-orientation: mixed !important;
  white-space: normal !important;
  word-break: normal !important;
  overflow-wrap: break-word !important;
}

.quiz-question-title {
  color: var(--text-main);
  font-size: 1rem;
  line-height: 1.55;
}

.quiz-option {
  min-height: 50px;
  align-items: flex-start;
  border-radius: 13px;
}

.quiz-option span {
  width: auto !important;
  font-size: 0.92rem;
  line-height: 1.5;
}

/* Login */
.login-shell--minimal {
  padding: calc(env(safe-area-inset-top, 0px) + 1.5rem) 1rem
    calc(env(safe-area-inset-bottom, 0px) + 1.5rem);
  background:
    radial-gradient(circle at 50% 38%, rgba(180, 155, 110, 0.11), transparent 18rem),
    #080808;
}

.login-minimal-card {
  width: min(460px, 100%);
  padding: clamp(1.5rem, 5vw, 2.35rem);
  border-radius: 22px;
  background: rgba(14, 14, 13, 0.96);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.45);
}

.login-wordmark {
  font-size: clamp(2.5rem, 9vw, 4rem);
  letter-spacing: 0.24em;
}

.login-action-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: stretch;
  gap: 0.65rem;
}

.login-action-row .button {
  min-width: 0;
}

@media (max-width: 1180px) {
  .topbar--planner {
    grid-template-columns: 1fr;
  }

  .top-actions--planner {
    width: 100%;
  }

  .topbar-session {
    margin-left: auto;
  }

  .planner-toolbar {
    align-items: stretch;
  }

  .planner-toolbar-main,
  .planner-toolbar-side {
    width: 100%;
  }

  .planner-toolbar-side {
    justify-content: space-between;
  }
}

@media (max-width: 860px) {
  :root {
    --page-gutter: clamp(0.65rem, 2.6vw, 1rem);
  }

  .app-shell,
  .app-shell--focused {
    width: 100%;
    min-width: 0;
    padding: calc(env(safe-area-inset-top, 0px) + 0.7rem) var(--page-gutter)
      calc(env(safe-area-inset-bottom, 0px) + 1.1rem);
  }

  .topbar--planner {
    display: flex;
    width: 100%;
    min-width: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 0.65rem;
    padding: 0.68rem;
  }

  .topbar-primary--planner {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    width: 100%;
    min-width: 0;
    gap: 0.6rem;
  }

  .planner-wordmark {
    align-self: center;
    padding-right: 0.65rem;
    font-size: 1.12rem;
    letter-spacing: 0.16em;
  }

  .topbar-tabs--planner {
    width: 100%;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
  }

  .tab-button {
    flex: 1 0 auto;
    min-height: 40px;
    padding: 0.55rem 0.72rem;
    font-size: 0.8rem;
  }

  .top-actions--planner {
    display: flex;
    width: 100%;
    min-width: 0;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 0.45rem;
  }

  .topbar-session {
    flex: 1 1 260px;
    width: auto;
    min-width: 0;
    margin-left: auto;
    padding: 0.35rem 0.45rem 0.35rem 0.7rem;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.025);
  }

  .topbar-account-copy {
    flex: 1 1 auto;
    max-width: none;
  }

  .planner-toolbar {
    padding: 0.62rem;
  }

  .planner-toolbar-main {
    display: grid;
    gap: 0.55rem;
  }

  .planner-client-picker--inline {
    width: 100%;
    max-width: none;
  }

  .planner-legend--minimal {
    min-width: 0;
  }

  .planner-toolbar-side {
    gap: 0.45rem;
  }

  .planner-week-pill {
    width: 100%;
  }

  .planner-controls--minimal {
    width: 100%;
  }

  .planner-controls--minimal .ghost-button {
    width: auto;
  }

  .planner-mobile {
    gap: 0.65rem;
  }

  .day-column--mobile {
    padding: 0.82rem;
  }

  .day-timeline--mobile {
    min-height: 900px;
  }

  .workspace-stack {
    gap: 0.7rem;
  }

  .section-card {
    border-radius: 19px;
  }

  .document-frame,
  .document-image,
  .document-canvas-shell {
    min-height: 70dvh;
    max-height: 70dvh;
  }
}

@media (max-width: 580px) {
  body {
    font-size: 14px;
  }

  .topbar--planner {
    margin-bottom: 0.6rem;
    border-radius: 16px;
  }

  .topbar-primary--planner {
    grid-template-columns: 1fr;
  }

  .planner-wordmark {
    justify-self: start;
    padding: 0 0 0.45rem;
    border-right: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  }

  .topbar-tabs--planner {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(max-content, 1fr);
    gap: 0.3rem;
  }

  .tab-button {
    width: auto;
    padding-inline: 0.62rem;
  }

  .top-actions--planner .install-button,
  .top-actions--planner .ghost-button {
    flex: 1 1 calc(50% - 0.25rem);
    width: auto;
    min-width: 0;
  }

  .topbar-session {
    flex: 1 1 100%;
    width: 100%;
    margin: 0;
  }

  .topbar-account-label {
    font-size: 0.55rem;
  }

  .topbar-account-name {
    font-size: 0.8rem;
  }

  .topbar-logout-button {
    width: auto;
    min-height: 38px;
  }

  .notice {
    margin-bottom: 0.6rem;
    padding: 0.62rem 0.72rem;
    font-size: 0.78rem;
  }

  .planner-toolbar-main {
    min-width: 0;
  }

  .planner-legend-list--minimal {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
    overflow: visible;
    gap: 0.35rem;
  }

  .legend-chip--minimal {
    width: 100%;
    min-width: 0;
    min-height: 42px;
    justify-content: flex-start;
    padding-inline: 0.5rem;
    font-size: 0.72rem;
  }

  .day-tabs {
    gap: 0.25rem;
  }

  .day-tabs .chip {
    min-height: 40px;
    font-size: 0.66rem;
  }

  .day-column--mobile {
    border-radius: 17px;
  }

  .day-timeline--mobile {
    min-height: 870px;
  }

  .section-header {
    gap: 0.65rem;
  }

  .section-header h2 {
    font-size: 1.25rem;
  }

  .section-header p {
    font-size: 0.84rem;
  }

  .modal-backdrop {
    align-items: end;
    padding: 0;
  }

  .modal-card {
    width: 100%;
    max-height: 94dvh;
    padding: 1rem;
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 22px 22px 0 0;
  }

  .modal-actions > * {
    min-height: 48px;
  }

  .video-quiz-cue {
    margin-top: 0.55rem;
  }

  .quiz-question {
    padding: 0.85rem;
    overflow: visible;
  }

  .quiz-question-title {
    font-size: 0.96rem;
  }

  .quiz-option span {
    font-size: 0.88rem;
  }

  .login-action-row {
    grid-template-columns: 1fr;
  }

  .login-action-row .button,
  .login-action-row .ghost-button {
    width: 100%;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .topbar--planner,
  .notice,
  .planner-toolbar,
  .workspace-stack > .section-card,
  .login-minimal-card {
    animation: timfit-surface-in 0.34s ease both;
  }

  .workspace-stack > .section-card:nth-child(2) {
    animation-delay: 0.04s;
  }

  .workspace-stack > .section-card:nth-child(3) {
    animation-delay: 0.08s;
  }
}

@keyframes timfit-surface-in {
  from {
    opacity: 0;
    transform: translateY(5px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}
