:root { font-family: sans-serif; }

* { box-sizing: border-box; font-family: inherit; }

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: color-mix(in srgb, var(--paper) calc(var(--bg-opacity) * 100%), transparent);
}

main {
  width: min(100% - 32px, 820px);
  flex: 1 0 auto;
  margin: 0 auto;
  padding: 16px 0 16px;
}

.app-promo-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
  padding: 10px 16px;
  color: #fff;
  background: var(--accent);
  font-weight: 700;
  font-size: 0.85rem;
  text-align: center;
}

.app-promo-download {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  padding: 6px 14px;
  color: var(--accent);
  background: #fff;
  border-radius: 999px;
  font-weight: 800;
  font-size: 0.78rem;
  text-decoration: none;
  white-space: nowrap;
  transition: background 160ms ease;
}

.app-promo-download:hover,
.app-promo-download:focus-visible {
  background: #f2f2f2;
}

.app-footer {
  padding: 16px;
  text-align: center;
}

.app-disclaimer {
  margin: 0 0 6px;
  color: var(--muted);
  font-weight: 700;
  font-size: 0.62rem;
  line-height: 1.4;
  opacity: 0.4;
}

.app-footer a {
  color: var(--muted);
  font-weight: 700;
  font-size: 0.7rem;
  text-decoration: none;
  opacity: 0.4;
  transition: opacity 160ms ease;
}

.app-footer a:hover,
.app-footer a:focus-visible {
  opacity: 1;
  text-decoration: underline;
}

header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 10px;
}

.electron-version-tag {
  display: none;
}

.header-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  align-self: flex-end;
  gap: 8px;
}

.add-timer {
  flex: 0 0 auto;
}

.title-row {
  display: flex;
  align-items: center;
  gap: 5px;
}

.app-logo {
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  image-rendering: pixelated;
}

h1 {
  margin: 0;
  color: var(--accent);
  font-size: 1.6rem;
  line-height: 0.9;
  letter-spacing: -0.06em;
  margin: 4px 0 0;
}

.version-tag {
  position: relative;
  top: 5px;
  margin-left: 6px;
  color: var(--accent);
  font-weight: 700;
  font-size: 0.6rem;
  letter-spacing: 0;
  vertical-align: middle;
}

.subtitle {
  margin: 8px 0 0;
  color: var(--muted);
  font-weight: 700;
  font-size: 0.75rem;
  line-height: 1.2;
}

.timer-card {
  position: relative;
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: color-mix(in srgb, var(--card) calc(var(--panel-opacity) * 100%), transparent);
  cursor: grab;
  transition: transform 160ms ease, box-shadow 160ms ease, opacity 160ms ease;
}

.timer-card:active {
  cursor: grabbing;
}

.timer-card::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  border-radius: inherit;
  background-image: var(--timer-icon, none);
  background-repeat: no-repeat;
  background-position: center;
  background-size: 128px 128px;
  image-rendering: pixelated;
  opacity: 0.1;
  pointer-events: none;
}

.timer-card.is-dragging {
  opacity: 0.88;
  transform: translate(-8px, -8px);
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.4);
  cursor: grabbing;
}

@keyframes timer-blink {
  0% { opacity: 1; }
  100% { opacity: 0; }
}

.timer-card.is-finished::after {
  position: absolute;
  inset: 0;
  z-index: 2;
  border-radius: 13px;
  background: #fff;
  content: "";
  pointer-events: none;
  animation: timer-blink 1s linear infinite;
}

.timer-card.is-finished::before {
  z-index: 3;
  opacity: 1;
  animation: timer-blink 1s linear infinite;
}

.draft-host {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: auto;
}

.draft-host .timer-card {
  display: contents;
}

.draft-host .timer-card > *:not(.settings-modal) {
  display: none;
}

.draft-host .settings-modal {
  pointer-events: auto;
}

.timer-card > .timer-progress-ring {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  overflow: visible;
  transition: opacity 160ms ease;
}

.timer-card.is-running > .timer-progress-ring,
.timer-card.has-progress > .timer-progress-ring {
  opacity: 1;
}

.timer-card.has-progress:not(.is-running):not(.is-finished) > .timer-progress-ring {
  opacity: 0.5;
}

.timer-progress-ring rect {
  x: 2px;
  y: 2px;
  width: calc(100% - 4px);
  height: calc(100% - 4px);
  rx: 11px;
  fill: none;
  stroke: var(--accent);
  stroke-width: 6px;
  stroke-linecap: round;
  stroke-dasharray: 1;
  stroke-dashoffset: calc(1 - var(--progress-fraction, 1));
  transition: stroke-dashoffset 160ms linear;
}

.timer-card > * {
  position: relative;
  z-index: 1;
}

.timer-card-header {
  grid-column: 1 / -1;
}

.timer-progress {
  position: relative;
  display: grid;
  min-width: 0;
  grid-template-columns: 1fr;
  align-items: center;
  gap: 16px;
  grid-column: 1 / -1;
  border-radius: 8px;
}

.section-title {
  display: block;
  margin-bottom: 24px;
  color: var(--ink);
  font-weight: 700;
  font-size: 1.15rem;
}

.settings-modal {
  width: min(100% - 32px, 356px);
  max-height: none;
  overflow: visible;
  padding: 12px;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.settings-modal::backdrop {
  background: rgba(0, 0, 0, 0.58);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.settings-modal-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.settings-modal .section-title {
  margin: 0;
  font-size: 0.92rem;
}

.confirm-message {
  margin: 0;
  color: var(--muted);
  font-weight: 700;
  font-size: 0.85rem;
  line-height: 1.4;
}

.settings-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 10px;
}

.settings-actions:has(> button:only-child) {
  grid-template-columns: 1fr;
}

.settings-actions button {
  padding: 8px 12px;
  font-size: 0.82rem;
}

.timer-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 8px;
}

.timer-card-header {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
}

.timer-shortcut-badge {
  display: inline-grid;
  min-width: 40px;
  min-height: 32px;
  place-items: center;
  padding: 6px 10px;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #303b47;
  font-weight: 700;
  font-size: 0.8rem;
  white-space: nowrap;
}

.timer-label {
  display: block;
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  font-weight: 600;
  font-size: 1rem;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.global-shortcut {
  margin-bottom: 18px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
}

.timer-display {
  position: relative;
  display: grid;
  place-self: center;
  justify-items: center;
  align-content: center;
  gap: 6px;
  padding: 4px 0;
}

.timer-display strong {
  color: var(--ink);
  font-family: serif;
  font-weight: 400;
  font-size: 3.4rem;
  letter-spacing: 0;
}

.timer-ms {
  position: absolute;
  right: -30px;
  bottom: 12px;
  color: var(--muted);
  font-family: serif;
  font-weight: 800;
  font-size: 1rem;
}

.controls {
  width: min(100%, 390px);
  min-width: 0;
  margin: 0 auto;
}

.control-label {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-weight: 700;
  font-size: 0.64rem;
  line-height: 1;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.name-field {
  display: grid;
  gap: 3px;
  margin-bottom: 10px;
}

.name-field .control-label,
.duration-field .control-label {
  margin-bottom: 0;
}

.name-input {
  width: 100%;
  padding: 6px 8px;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 4px;
  font-weight: 700;
  font-size: 0.78rem;
}

.name-input:focus {
  border-color: var(--accent);
  outline: 3px solid rgba(232, 93, 63, 0.2);
}

.duration-setting {
  display: grid;
  gap: 3px;
  margin-bottom: 10px;
}

.duration-setting .control-label {
  margin-bottom: 0;
}

.duration-setting-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.duration-setting .duration-fields {
  margin-bottom: 0;
}

.duration-fields {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 4px;
  margin-bottom: 10px;
  padding: 2px 6px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 4px;
}

.duration-fields:focus-within {
  border-color: var(--accent);
  outline: 3px solid rgba(232, 93, 63, 0.2);
}

.duration-separator {
  color: var(--muted);
  font-weight: 600;
  font-size: .8rem;
  margin-top: 2px;
  line-height: 1;
}

.duration-input {
  width: 100%;
  min-width: 0;
  padding: 4px;
  color: var(--ink);
  background: transparent;
  border: 0;
  border-radius: 0;
  font-weight: 600;
  line-height: 1;
  text-align: center;
  appearance: textfield;
}

.duration-input::-webkit-inner-spin-button,
.duration-input::-webkit-outer-spin-button {
  margin: 0;
  appearance: none;
}

.duration-input:focus {
  outline: 0;
}

.duration-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.duration-preset {
  padding: 2px 7px;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.58rem;
}

.duration-preset:hover,
.duration-preset:focus-visible {
  color: var(--ink);
  background: #303b47;
  border-color: var(--accent);
}

.shortcut-setting {
  display: grid;
  grid-template-columns: 1fr;
  gap: 3px;
  align-items: center;
  margin-bottom: 2px;
}

.shortcut-setting .control-label {
  margin-bottom: 0;
}

.shortcut-input {
  width: 100%;
  box-sizing: border-box;
  overflow: hidden;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--ink);
  background: #303b47;
  font-weight: 700;
  font-size: 0.78rem;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
  cursor: pointer;
  caret-color: transparent;
  margin-bottom: 10px;
}

.shortcut-input:hover {
  transform: none;
}

.shortcut-input:focus {
  outline: none;
}

.shortcut-input.is-setting-shortcut {
  border-color: var(--accent);
  outline: 3px solid rgba(232, 93, 63, 0.2);
  color: var(--accent);
}

.icon-setting {
  margin-bottom: 10px;
}

.icon-options {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.icon-option {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.icon-option:hover,
.icon-option:focus-visible {
  background: #303b47;
}

.icon-option.is-selected {
  border-color: var(--accent);
}

.icon-option img {
  display: block;
  width: 32px;
  height: 32px;
  image-rendering: pixelated;
}

.icon-option-none {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  color: var(--muted);
  font-weight: 700;
  font-size: 0.62rem;
  line-height: 1;
  white-space: nowrap;
}

button {
  border: 0;
  border-radius: 4px;
  cursor: pointer;
  font: inherit;
  transition: transform 160ms ease, background 160ms ease, color 160ms ease;
}

button:focus-visible { outline: 3px solid rgba(232, 93, 63, 0.35); outline-offset: 3px; }

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  transform: none;
}

.primary {
  padding: 17px 20px;
  color: #fff;
  background: var(--accent);
  font-weight: 700;
  font-size: 1rem;
}

.primary:hover,
.primary:focus-visible {
  background: var(--accent-dark);
}

.secondary {
  padding: 13px 20px;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--line);
  font-weight: 700;
  font-size: 0.82rem;
}

.secondary:hover,
.secondary:focus-visible {
  color: var(--ink);
  background: #303b47;
}

.timer-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.timer-actions-group {
  display: flex;
  gap: 8px;
}

.timer-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--line);
}

.timer-action:hover,
.timer-action:focus-visible {
  color: var(--ink);
  background: #303b47;
}

.timer-card:not(.is-running):not(.is-finished) .start-button,
.timer-card.is-finished .reset-button {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}

.timer-card:not(.is-running):not(.is-finished) .start-button:hover,
.timer-card:not(.is-running):not(.is-finished) .start-button:focus-visible,
.timer-card.is-finished .reset-button:hover,
.timer-card.is-finished .reset-button:focus-visible {
  color: #fff;
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

.settings-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--line);
}

.settings-toggle:hover,
.settings-toggle:focus-visible {
  color: var(--ink);
  background: #303b47;
}

.add-timer,
.close-button,
.screen-settings-button {
  background: color-mix(in srgb, var(--paper) calc(var(--panel-opacity) * 100%), transparent);
}

.add-timer,
.close-button,
.screen-settings-button {
  padding: 12px;
  border-radius: 10px;
}

.close-button {
  display: none;
}

.opacity-setting {
  display: grid;
  margin-bottom: 16px;
}

.opacity-setting:last-of-type {
  margin-bottom: 28px;
}

.opacity-setting .control-label {
  margin-bottom: 0;
  margin-left: 2px;
}

.volume-setting .control-label {
  margin-left: 0;
}

.volume-setting {
  margin-bottom: 8px;
}

.alarm-type-setting {
  display: grid;
  grid-template-columns: 1fr;
  gap: 3px;
  align-items: center;
  margin-bottom: 10px;
}

.alarm-type-setting .control-label {
  margin-bottom: 0;
}

.select-wrapper {
  position: relative;
}

.select-wrapper svg {
  position: absolute;
  top: 50%;
  right: 8px;
  transform: translateY(-50%);
  color: var(--ink);
  pointer-events: none;
}

.alarm-type-select {
  width: 100%;
  box-sizing: border-box;
  padding: 6px 28px 6px 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--ink);
  background: #303b47;
  font-weight: 700;
  font-size: 0.78rem;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}

.alarm-type-select:focus {
  outline: none;
  border-color: var(--accent);
}

.opacity-setting-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.opacity-slider {
  width: 100%;
  accent-color: var(--accent);
  cursor: pointer;
}

.opacity-slider::-webkit-slider-thumb {
  cursor: pointer;
}

.opacity-slider::-webkit-slider-runnable-track {
  cursor: pointer;
}

.opacity-slider::-moz-range-thumb {
  cursor: pointer;
}

.opacity-slider::-moz-range-track {
  cursor: pointer;
}

.duration-hint {
  color: var(--muted);
  opacity: 0.6;
  font-weight: 400;
  font-size: 0.6rem;
}

.settings-modal {
  cursor: default;
}

.settings-modal button {
  cursor: pointer;
}

.settings-modal input {
  cursor: text;
}

.settings-modal input.shortcut-input {
  cursor: pointer;
}