/* Shared pieces, built only from tokens.css. How each screen is laid out stays in styles.css and the feature files, which load after this one. */

/* ------------------------------------------------ elements */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: var(--text-base);
  line-height: 1.6;
  overflow-wrap: break-word;
  font-synthesis: none;
}

/* Korean breaks between words, not inside them. Japanese and Chinese keep their own rules. */
:lang(ko) {
  word-break: keep-all;
}

button, input, select, textarea {
  font: inherit;
}

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

button {
  color: inherit;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: .5;
}

a {
  color: inherit;
  text-decoration: none;
}

h1, h2, h3, p {
  margin: 0;
}

h1, h2, h3 {
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -.02em;
}

h1 {
  font-size: var(--text-2xl);
}

h2 {
  font-size: var(--text-xl);
}

h3 {
  font-size: var(--text-md);
}

em {
  font-style: normal;
}

p {
  color: var(--muted);
}

hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: var(--space-6) 0;
}

small {
  font-size: var(--text-xs);
}

svg.icon {
  width: 20px;
  height: 20px;
  flex: none;
  vertical-align: middle;
}

button .icon, a .icon {
  pointer-events: none;
}

kbd {
  font: inherit;
  font-size: var(--text-xs);
  color: var(--muted);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-xs);
  padding: 0 var(--space-1);
}

:focus-visible {
  outline: 2px solid var(--pine);
  outline-offset: 2px;
}

.skip-link {
  position: fixed;
  top: -100px;
  left: 12px;
  z-index: 1000;
  padding: var(--space-3);
  background: var(--surface);
  border-radius: var(--radius-sm);
}

.skip-link:focus {
  top: 10px;
}

.sr-only {
  position: absolute!important;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* ------------------------------------------------ quiet text */
.muted, .optional {
  color: var(--muted);
  font-size: var(--text-sm);
}

.optional {
  font-weight: 400;
  margin-left: var(--space-1);
}

/* English labels above headings said nothing the heading did not. */
.eyebrow, .nav-heading, .nav-dot, .greeting-spark, .sidebar-note {
  display: none;
}

.tiny-label {
  display: inline-block;
  padding: 2px var(--space-2);
  border-radius: var(--radius-xs);
  background: var(--tint);
  color: var(--ink);
  font-size: var(--text-xs);
  font-weight: 600;
  white-space: nowrap;
}

.tiny-label.warning {
  background: var(--warn-tint);
  color: var(--warn);
}

.language-pill {
  display: inline-block;
  padding: 0 var(--space-2);
  border-radius: var(--radius-xs);
  background: var(--pine);
  color: var(--on-pine);
  font-size: var(--text-xs);
  font-weight: 600;
  line-height: 1.6;
}

.count-badge, .date-chip {
  padding: var(--space-1) var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-full);
  color: var(--muted);
  font-size: var(--text-sm);
  white-space: nowrap;
}

/* ------------------------------------------------ buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 46px;
  padding: 0 var(--space-5);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--tint);
  color: var(--ink);
  font-weight: 600;
  line-height: 1.3;
  text-align: center;
  transition: transform var(--press), box-shadow var(--press), background-color var(--press);
}

.btn:hover:not(:disabled) {
  background: var(--line);
}

.btn.primary {
  background: var(--pine);
  color: var(--on-pine);
  box-shadow: var(--echo);
}

.btn.primary:hover:not(:disabled) {
  background: var(--pine-soft);
}

/* The echo catches up with the button: the press is the shadowing idea in small. */
.btn.primary:active:not(:disabled) {
  transform: translate(4px, 4px);
  box-shadow: var(--echo-off);
}

.btn.primary:disabled {
  box-shadow: none;
}

.btn.secondary {
  background: transparent;
  border-color: var(--pine);
  color: var(--pine);
}

.btn.secondary:hover:not(:disabled) {
  background: var(--tint);
}

.btn.danger {
  background: transparent;
  border-color: var(--danger);
  color: var(--danger);
}

.btn.danger:hover:not(:disabled) {
  background: var(--danger-tint);
}

.btn.small {
  min-height: 40px;
  padding: 0 var(--space-3);
  font-size: var(--text-sm);
}

.btn.small.primary {
  box-shadow: var(--echo-sm);
}

.btn.full {
  width: 100%;
}

.text-btn {
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 44px;
  padding: var(--space-2) var(--space-1);
  border: 0;
  background: none;
  color: var(--pine-soft);
  font-size: var(--text-sm);
  font-weight: 600;
}

.text-btn:hover:not(:disabled) {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.text-btn .icon {
  width: 18px;
  height: 18px;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
}

.icon-button:hover:not(:disabled) {
  background: var(--tint);
}

.favorited {
  color: var(--pine)!important;
}

.favorited svg {
  fill: var(--lime);
  stroke: var(--pine);
}

/* ------------------------------------------------ forms */
label {
  display: block;
  margin-bottom: var(--space-4);
  font-size: var(--text-sm);
  font-weight: 600;
}

label>input, label>select, label>textarea {
  margin-top: var(--space-2);
}

form label select, form label input {
  font-weight: 400;
}

input, select, textarea {
  width: 100%;
  min-height: 46px;
  padding: var(--space-3) var(--space-3);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font-size: var(--text-base);
  outline: none;
  transition: box-shadow var(--press);
}

/* Where you are typing is where you are acting: it gets the echo. */
input:focus, textarea:focus, select:focus {
  border-color: var(--pine);
  box-shadow: var(--echo-sm);
}

input::placeholder, textarea::placeholder {
  color: var(--muted);
}

textarea {
  resize: vertical;
  line-height: 1.6;
}

input[type=checkbox], input[type=radio] {
  accent-color: var(--pine);
}

fieldset {
  min-width: 0;
  margin: 0 0 var(--space-4);
  padding: 0;
  border: 0;
}

legend {
  margin-bottom: var(--space-2);
  font-size: var(--text-sm);
  font-weight: 600;
}

form>.btn {
  margin-top: var(--space-2);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
}

.form-error {
  margin: var(--space-3) 0;
  padding: var(--space-3);
  border-radius: var(--radius-sm);
  background: var(--danger-tint);
  color: var(--danger);
  font-size: var(--text-sm);
}

.check-label {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  margin: var(--space-4) 0;
  font-size: var(--text-sm);
  font-weight: 400;
}

.check-label input {
  width: 18px;
  height: 18px;
  min-height: 18px;
  margin-top: 2px;
}

/* A small check box or radio with its text, on one line */
.check-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin: var(--space-2) 0;
  font-weight: 400;
}

.check-row input {
  flex: none;
  width: 18px;
  height: 18px;
  min-height: 0;
  margin: 0;
  padding: 0;
}

.search-field {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 215px;
  max-width: 300px;
  margin: 0;
  padding: 0 var(--space-3);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-weight: 400;
  transition: box-shadow var(--press);
}

.search-field .icon {
  width: 16px;
  height: 16px;
  color: var(--muted);
}

.search-field input {
  min-height: 40px;
  margin: 0;
  padding: var(--space-2) 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  font-size: var(--text-sm);
}

.search-field:focus-within {
  border-color: var(--pine);
  box-shadow: var(--echo-sm);
}

/* ------------------------------------------------ choosing one of a few */
.segmented, .mode-tabs {
  display: flex;
  gap: var(--space-1);
  padding: var(--space-1);
  border-radius: var(--radius-sm);
  background: var(--tint);
}

.segmented {
  margin: var(--space-6) 0;
}

.mode-tabs {
  margin: var(--space-5) 0 var(--space-3);
}

.segmented button, .mode-tabs button {
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 44px;
  padding: var(--space-2);
  border: 0;
  border-radius: var(--radius-xs);
  background: none;
  color: var(--muted);
  font-size: var(--text-sm);
}

.mode-tabs .icon {
  width: 18px;
  height: 18px;
}

.segmented button[aria-selected=true], .mode-tabs button[aria-selected=true] {
  background: var(--surface);
  color: var(--pine);
  font-weight: 600;
}

.filter-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: var(--space-5) 0 var(--space-4);
}

.filter-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
}

.filter-tabs button {
  min-height: 36px;
  padding: var(--space-1) var(--space-3);
  border: 0;
  border-radius: var(--radius-xs);
  background: transparent;
  color: var(--muted);
  font-size: var(--text-sm);
}

.filter-tabs button:hover {
  background: var(--tint);
}

.filter-tabs button.selected {
  background: var(--pine);
  color: var(--on-pine);
  font-weight: 600;
}

/* ------------------------------------------------ notes and states */
.hint-box {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  margin: var(--space-4) 0;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-sm);
  background: var(--tint);
  color: var(--ink);
  font-size: var(--text-sm);
}

.hint-box .icon {
  width: 18px;
  height: 18px;
  margin-top: 1px;
}

.hint-box a {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.preview-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  background: var(--lime-soft);
  color: var(--ink);
  font-size: var(--text-sm);
  text-align: center;
}

.preview-banner .icon {
  width: 16px;
  height: 16px;
}

.media-note {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  margin-top: var(--space-2);
  color: var(--muted);
  font-size: var(--text-sm);
}

.media-note .icon {
  flex: none;
  width: 16px;
  height: 16px;
  margin-top: 2px;
}

.media-note a {
  text-decoration: underline;
  text-underline-offset: 3px;
  white-space: nowrap;
}

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--tint);
  border-top-color: var(--pine);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

.small-spinner {
  width: 18px;
  height: 18px;
  border-width: 2px;
}

.progress-track, .card-progress {
  height: 6px;
  border-radius: var(--radius-full);
  background: var(--tint);
  overflow: hidden;
}

.card-progress {
  height: 4px;
  margin-top: var(--space-2);
}

.progress-track span, .card-progress span {
  display: block;
  height: 100%;
  background: var(--pine);
}

.progress-track span {
  width: 0;
  transition: width .1s linear;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  min-height: 240px;
  padding: var(--space-14) var(--space-6);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  text-align: center;
}

.empty-state>span:first-child {
  display: grid;
  place-items: center;
  color: var(--pine);
}

.empty-state h2 {
  font-size: var(--text-lg);
}

.empty-state h3 {
  font-size: var(--text-md);
}

.empty-state p {
  max-width: 550px;
  font-size: var(--text-base);
}

.empty-state .btn {
  margin-top: var(--space-2);
}

.empty-inline {
  padding: var(--space-8);
  color: var(--muted);
  text-align: center;
}

.empty-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: var(--space-8);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  font-size: var(--text-sm);
}

.empty-card h3 {
  margin-bottom: var(--space-3);
}

.toast {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-sm);
  background: var(--pine);
  color: var(--on-pine);
  font-size: var(--text-sm);
  box-shadow: var(--shadow-overlay);
  animation: slidein .2s ease-out;
}

.toast.error {
  background: var(--danger);
}

.toast.info {
  background: var(--ink);
}

/* ------------------------------------------------ surfaces */
.settings-card {
  min-width: 0;
  padding: var(--space-6);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
}

.settings-card .panel-heading {
  padding: 0;
}

.settings-card .panel-heading>.icon {
  color: var(--pine-soft);
}

.settings-card form .btn {
  margin-top: var(--space-4);
}

.settings-card .hint-box {
  margin-bottom: 0;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: 0 var(--space-5);
}

.panel-heading h2 {
  font-size: var(--text-md);
}

.panel-heading h2>span {
  margin-left: var(--space-1);
  color: var(--muted);
  font-size: var(--text-sm);
  font-weight: 400;
}

.page-intro {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3) var(--space-5);
  margin-bottom: var(--space-6);
}

/* The heading takes the line; an action beside it drops below when there is no room instead of being squeezed. */
.page-intro>div:first-child {
  flex: 1 1 260px;
  min-width: 0;
}

.page-intro>.btn {
  flex: none;
}

.page-intro p {
  margin-top: var(--space-1);
  font-size: var(--text-base);
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
}

.section-heading h2 {
  font-size: var(--text-lg);
}

.section-heading h2 span {
  margin-left: var(--space-2);
  color: var(--muted);
  font-size: var(--text-base);
  font-weight: 400;
}

.section-heading p {
  margin-top: var(--space-1);
  font-size: var(--text-sm);
}

.modal {
  width: 620px;
  max-width: calc(100vw - 28px);
  max-height: 90dvh;
  padding: var(--space-8);
  border: 0;
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-overlay);
}

.modal::backdrop {
  background: color-mix(in srgb, var(--pine) 55%, transparent);
}

.modal-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.modal-heading h2 {
  margin-bottom: var(--space-2);
  font-size: var(--text-xl);
}

.modal-heading p {
  font-size: var(--text-sm);
}

.modal-heading .icon-button svg {
  width: 18px;
  height: 18px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
  margin-top: var(--space-6);
  padding-top: var(--space-5);
  border-top: 1px solid var(--line);
}

/* ------------------------------------------------ the frame around every screen */
.sidebar {
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  padding: var(--space-6) var(--space-3);
  border-right: 1px solid var(--line);
  background: var(--paper);
}

.sidebar nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: var(--space-6);
}

.brand-word {
  font-size: var(--text-lg);
  font-weight: 600;
  letter-spacing: -.02em;
  line-height: 1.1;
}

.brand-word>span {
  color: var(--pine-soft);
  font-weight: 400;
}

/* The tag line under the logo cannot be read at this size. */
.brand-word small {
  display: none;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: 44px;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  color: var(--ink);
  font-size: var(--text-base);
}

.nav-link .icon {
  width: 18px;
  height: 18px;
}

.nav-link:not(.active):hover {
  background: var(--tint);
}

.nav-link.active {
  background: var(--lime);
  color: var(--pine);
  font-weight: 600;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 72px;
  padding: 0 var(--space-10);
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}

/* Only the screen's name: the English trail before it is dropped by size so the markup stays as it is. */
.topbar-location {
  font-size: 0;
}

.topbar-location span {
  display: none;
}

.topbar-location strong {
  color: var(--muted);
  font-size: var(--text-sm);
  font-weight: 400;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--pine);
  color: var(--lime);
  font-size: var(--text-sm);
  font-weight: 600;
}

.avatar.large {
  width: 52px;
  height: 52px;
  font-size: var(--text-lg);
}

/* ------------------------------------------------ small layout helpers (they replace style="" in the screens) */
.row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.row.end {
  justify-content: flex-end;
}

.plain-list {
  display: grid;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.item-box {
  padding: var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.gap-above {
  margin-top: var(--space-2);
}

.span-all {
  grid-column: 1 / -1;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table td {
  padding: var(--space-1) var(--space-2);
  border-bottom: 1px solid var(--line);
}

.data-table td:first-child {
  min-width: 12em;
}
